diff --git a/CMake/FindOpenCL.cmake b/CMake/FindOpenCL.cmake index 34e85fa8d0..e30fb7a484 100644 --- a/CMake/FindOpenCL.cmake +++ b/CMake/FindOpenCL.cmake @@ -1,59 +1,89 @@ -set(ENV_ATISTREAMSDKROOT $ENV{ATISTREAMSDKROOT}) -if(ENV_ATISTREAMSDKROOT) - find_path( - OpenCL_INCLUDE_DIR - NAMES CL/cl.h OpenCL/cl.h - PATHS $ENV{ATISTREAMSDKROOT}/include - NO_DEFAULT_PATH - ) +# - Try to find OpenCL +# This module tries to find an OpenCL implementation on your system. It supports +# AMD / ATI, Apple and NVIDIA implementations, but should work, too. +# +# To set manually the paths, define these environment variables: +# OpenCL_INCPATH - Include path (e.g. OpenCL_INCPATH=/opt/cuda/4.0/cuda/include) +# OpenCL_LIBPATH - Library path (e.h. OpenCL_LIBPATH=/usr/lib64/nvidia) +# +# Once done this will define +# OPENCL_FOUND - system has OpenCL +# OPENCL_INCLUDE_DIRS - the OpenCL include directory +# OPENCL_LIBRARIES - link these to use OpenCL +# +# WIN32 should work, but is untested - if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - if(CMAKE_SIZEOF_VOID_P EQUAL 4) - set( - OpenCL_LIB_SEARCH_PATH - ${OpenCL_LIB_SEARCH_PATH} - $ENV{ATISTREAMSDKROOT}/lib/x86 - ) - else(CMAKE_SIZEOF_VOID_P EQUAL 4) - set( - OpenCL_LIB_SEARCH_PATH - ${OpenCL_LIB_SEARCH_PATH} - $ENV{ATISTREAMSDKROOT}/lib/x86_64 - ) - endif(CMAKE_SIZEOF_VOID_P EQUAL 4) - endif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - find_library( - OpenCL_LIBRARY - NAMES OpenCL - PATHS ${OpenCL_LIB_SEARCH_PATH} - NO_DEFAULT_PATH - ) -else(ENV_ATISTREAMSDKROOT) - find_path( - OpenCL_INCLUDE_DIR - NAMES CL/cl.h OpenCL/cl.h - ) +FIND_PACKAGE(PackageHandleStandardArgs) + +SET (OPENCL_VERSION_STRING "0.1.0") +SET(OPENCL_VERSION_MAJOR 0) +SET(OPENCL_VERSION_MINOR 1) +SET(OPENCL_VERSION_PATCH 0) + +IF(APPLE) + + FIND_LIBRARY(OPENCL_LIBRARIES OpenCL DOC "OpenCL lib for OSX") + FIND_PATH(OPENCL_INCLUDE_DIRS OpenCL/cl.h DOC "Include for OpenCL on OSX") + FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS OpenCL/cl.hpp DOC "Include for OpenCL CPP bindings on OSX") + +ELSE() + IF (WIN32) + + FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h) + FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp) + + IF(CMAKE_SIZEOF_VOID_P MATCHES "8") + SET(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86_64") + if(NOT IS_DIRECTORY ${OPENCL_LIB_DIR}) + SET(OPENCL_LIB_DIR "$ENV{CUDA_PATH}/lib/x64") + endif() + ELSE() + SET(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86") + if(NOT IS_DIRECTORY ${OPENCL_LIB_DIR}) # need to convert path in the cmake style ? + SET(OPENCL_LIB_DIR "$ENV{CUDA_PATH}/lib/Win32") + endif() + ENDIF() + file(TO_CMAKE_PATH ${OPENCL_LIB_DIR} OPENCL_LIB_DIR) + GET_FILENAME_COMPONENT(OPENCL_LIB_DIR ${OPENCL_LIB_DIR} ABSOLUTE) + + FIND_LIBRARY(OPENCL_LIBRARIES OpenCL.lib PATHS ${OPENCL_LIB_DIR} ENV OpenCL_LIBPATH) + + GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE) - find_library( - OpenCL_LIBRARY - NAMES OpenCL + # On Win32 search relative to the library + FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS "${_OPENCL_INC_CAND}" ENV OpenCL_INCPATH) + FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS "${_OPENCL_INC_CAND}" ENV OpenCL_INCPATH) + + ELSE (WIN32) + + # Unix style platforms + FIND_LIBRARY(OPENCL_LIBRARIES OpenCL + PATHS ENV LD_LIBRARY_PATH ENV OpenCL_LIBPATH + ) + + GET_FILENAME_COMPONENT(OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH) + GET_FILENAME_COMPONENT(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE) + + # The AMD SDK currently does not place its headers + # in /usr/include, therefore also search relative + # to the library + FIND_PATH(OPENCL_INCLUDE_DIRS CL/cl.h PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include" "/opt/AMDAPP/include" ENV OpenCL_INCPATH) + FIND_PATH(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include" "/opt/AMDAPP/include" ENV OpenCL_INCPATH) + + ENDIF (WIN32) + +ENDIF (APPLE) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS) + +IF(_OPENCL_CPP_INCLUDE_DIRS) + SET( OPENCL_HAS_CPP_BINDINGS TRUE ) + LIST( APPEND OPENCL_INCLUDE_DIRS ${_OPENCL_CPP_INCLUDE_DIRS} ) + # This is often the same, so clean up + LIST( REMOVE_DUPLICATES OPENCL_INCLUDE_DIRS ) +ENDIF(_OPENCL_CPP_INCLUDE_DIRS) + +MARK_AS_ADVANCED( + OPENCL_INCLUDE_DIRS ) -endif(ENV_ATISTREAMSDKROOT) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - OpenCL - DEFAULT_MSG - OpenCL_LIBRARY OpenCL_INCLUDE_DIR - ) - -if(OpenCL_FOUND) - set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) -else(OpenCL_FOUND) - set(OpenCL_LIBRARIES) -endif(OpenCL_FOUND) - -mark_as_advanced( - OpenCL_INCLUDE_DIR - OpenCL_LIBRARY - ) + diff --git a/CMake/PackageDepends/MITK_OpenCL_Config.cmake b/CMake/PackageDepends/MITK_OpenCL_Config.cmake index dd1f160d2e..18ba488136 100644 --- a/CMake/PackageDepends/MITK_OpenCL_Config.cmake +++ b/CMake/PackageDepends/MITK_OpenCL_Config.cmake @@ -1,8 +1,8 @@ find_package(OpenCL REQUIRED) -list(APPEND ALL_LIBRARIES ${OpenCL_LIBRARY}) -list(APPEND ALL_INCLUDE_DIRECTORIES ${OpenCL_INCLUDE_DIR}) +list(APPEND ALL_LIBRARIES ${OPENCL_LIBRARIES}) +list(APPEND ALL_INCLUDE_DIRECTORIES ${OPENCL_INCLUDE_DIRS}) # on OS X the linker needs a flag pointing to the OpenCL.framework if(APPLE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework OpenCL") endif(APPLE) diff --git a/Modules/OpenCL/Documentation/doxygen/MitkOpenCL.dox b/Modules/OpenCL/Documentation/doxygen/MitkOpenCL.dox index e4f3b34e03..0ca4d070e5 100644 --- a/Modules/OpenCL/Documentation/doxygen/MitkOpenCL.dox +++ b/Modules/OpenCL/Documentation/doxygen/MitkOpenCL.dox @@ -1,49 +1,49 @@ /** \page MitkOpenCL_Example Examples This is a list of available examples: - \subpage MitkOpenCL_BinaryThresholdFilter */ /** \page MitkOpenCL_Overview The MITK OpenCL Module The MITK OpenCL Module provides a basic class structure to allow usage of OpenCL-accelerated parallel computing.

Build Instructions

The MITK OpenCL module needs an OpenCL Device ( most likely a graphics card, but works also on some CPUs ) and the corresponding driver. Furthermore the OpenCL library and the headers are needed. A list of supported hardware is provided by Khronos.org . For the driver and the libraries please look at the support pages of the hardware manufacturer. Quick Links to the most likely of them: - NVIDIA OpenCL Page - AMD/ATI OpenCL Page - Intel OpenCL SDK To activate the module, you have to activate the CMake option \verbatim MITK_USE_OpenCL \endverbatim The build system tries to find the OpenCL library and the include path automatically. If this attempt failes, you will be prompted to manually specify following variables: \verbatim -OpenCL_INCLUDE_DIR -OpenCL_LIBRARY +OPENCL_INCLUDE_DIRS +OPENCL_LIBRARIES \endverbatim

Detailed description

For own implementations, the OpenCL Module allows for building up a filtering pipeline in MITK Style ( see more in \ref PipelineingConceptPage ). The OpenCL filter can be simply connected also to an existing MITK image filtering pipeline since the mitk::OclImageToImageFilter provide a SetInput and GetOutput methods expecting an mitk::Image and returning it respectively.

Examples

Here is a list of \subpage MitkOpenCL_Example "examples": - \ref MitkOpenCL_BinaryThresholdFilter */