1 # **************************************************************************
2 # * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
4 # * Author: The ALICE Off-line Project. *
5 # * Contributors are mentioned in the code where appropriate. *
7 # * Permission to use, copy, modify and distribute this software and its *
8 # * documentation strictly for non-commercial purposes is hereby granted *
9 # * without fee, provided that the above copyright notice appears in all *
10 # * copies and that both the copyright notice and this permission notice *
11 # * appear in the supporting documentation. The authors make no claims *
12 # * about the suitability of this software for any purpose. It is *
13 # * provided "as is" without express or implied warranty. *
14 # **************************************************************************
17 set(MODULE AliHLTTPCCAGPUOpenCL)
19 # AMD APP SDK required for OpenCL tracker; it's using specific
20 # extensions (currently) not provided by other vendors.
21 # either set cmake variable via "-D$AMDAPPSDKROOT=/path/to/amdappsdkroot"
22 # or via environment variable $AMDAPPSDKROOT
24 set(AMDAPPSDKROOT $ENV{AMDAPPSDKROOT})
28 message(FATAL_ERROR "AMDAPPSDKROOT not set. Please install AMD APP SDK and set $AMDAPPSDKROOT or disable HLT_OPENCL.")
31 if(NOT "$ENV{GPU_FORCE_64BIT_PTR}" STREQUAL "1")
32 message(FATAL_ERROR "Please set env variable $GPU_FORCE_64BIT_PTR=1, required by HLT OpenCL tracker.")
35 #convenience variables
36 set(CAGPUDIR ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu)
39 link_directories(${AMDAPPSDKROOT}/lib/x86_64)
41 # build the OpenCL compile wrapper:
42 # -- checks the correct vendor implementation (AMD)
43 # -- builds binary code (blob) for the found platform(s)
44 add_executable(opencl_compiler ${CAGPUDIR}/makefiles/makefile_opencl_compiler.cpp)
45 target_link_libraries(opencl_compiler amdocl64 OpenCL)
47 #convenience variables
48 set(CL_SRC ${CAGPUDIR}/opencl/AliHLTTPCCAGPUTrackerOpenCL.cl )
49 set(CL_BIN ${CMAKE_CURRENT_BINARY_DIR}/AliHLTTPCCAGPUTrackerOpenCLCode.bin )
51 -I${AliRoot_SOURCE_DIR}/HLT/BASE
52 -I${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca
56 # executes OpenCL compiler wrapper to build binary object
59 COMMAND opencl_compiler -output-file ${CL_BIN} ${CL_SRC} -- ${CL_INC} -x clc++
60 MAIN_DEPENDENCY ${CL_SRC}
63 # make cmake compile the assembler file
64 set_source_files_properties(${CAGPUDIR}/makefiles/include.S PROPERTIES LANGUAGE CXX)
65 # add proper dependency on included binary code
66 set_source_files_properties(${CAGPUDIR}/makefiles/include.S PROPERTIES OBJECT_DEPENDS ${CL_BIN})
68 # bit of a hack, but otherwise dictionary compilation fails:
69 # defines __ROOT__; triggers "ifdef" in source code to circumvent broken cint behaviour with "volatile" keyword
70 # not sure why __ROOT__ is used here, could just as well be something else
71 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/G__AliHLTTPCCAGPUOpenCL.cxx PROPERTIES COMPILE_DEFINITIONS "__ROOT__")
73 # Module include folder
74 include_directories(${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu/opencl
75 ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/makefiles
76 ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu
77 ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca
80 # Additional include folders in alphabetical order except ROOT
81 include_directories(${ROOT_INCLUDE_DIRS}
82 ${AliRoot_SOURCE_DIR}/HLT/BASE
83 ${AMDAPPSDKROOT}/include
86 # Sources in alphabetical order
88 ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.cxx
89 AliHLTTPCCAGPUTrackerOpenCL.cxx
90 ${CAGPUDIR}/makefiles/include.S
93 # Headers from sources
95 ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.h
96 AliHLTTPCCAGPUTrackerOpenCL.h
101 ${CAGPUDIR}/AliHLTTPCCAGPUTrackerCommon.h
102 AliHLTTPCCAGPUTrackerOpenCLInternals.h
105 # Generate the dictionary
106 # It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument
107 get_directory_property(incdirs INCLUDE_DIRECTORIES)
108 generate_dictionary("${MODULE}" "" "${CINTHDRS}" "${incdirs}")
110 # Generate the ROOT map
111 generate_rootmap("${MODULE}" "" "")
113 # Add a library to the project using the specified source files
114 add_library(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)
115 #MAD OpenCL run-time and driver
116 target_link_libraries(${MODULE} amdocl64 OpenCL AliHLTTPC)
119 install(TARGETS ${MODULE}
120 ARCHIVE DESTINATION lib
121 LIBRARY DESTINATION lib)
123 install(FILES ${HDRS} DESTINATION include)