]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/cagpu/opencl/CMakeLists.txt
ea4a420aa91437e36e380ada990418cf33e6a2ae
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / cagpu / opencl / CMakeLists.txt
1 # **************************************************************************
2 # * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
3 # *                                                                        *
4 # * Author: The ALICE Off-line Project.                                    *
5 # * Contributors are mentioned in the code where appropriate.              *
6 # *                                                                        *
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 # **************************************************************************
15
16 # Module
17 set(MODULE AliHLTTPCCAGPUOpenCL)
18
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
23 if(NOT AMDAPPSDKROOT)
24     set(AMDAPPSDKROOT $ENV{AMDAPPSDKROOT})
25 endif()
26
27 if(NOT AMDAPPSDKROOT)
28     message(FATAL_ERROR "AMDAPPSDKROOT not set. Please install AMD APP SDK and set $AMDAPPSDKROOT or disable HLT_OPENCL.")
29 endif()
30
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.")
33 endif()
34
35 #convenience variables
36 set(CAGPUDIR ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu)
37
38 #libdir path
39 link_directories(${AMDAPPSDKROOT}/lib/x86_64)
40
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)
46
47 #convenience variables
48 set(CL_SRC ${CAGPUDIR}/opencl/AliHLTTPCCAGPUTrackerOpenCL.cl )
49 set(CL_BIN ${CMAKE_CURRENT_BINARY_DIR}/AliHLTTPCCAGPUTrackerOpenCLCode.bin )
50 set(CL_INC
51     -I${AliRoot_SOURCE_DIR}/HLT/BASE 
52     -I${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca
53     -I${CAGPUDIR}
54 )
55
56 # executes OpenCL compiler wrapper to build binary object
57 add_custom_command(
58     OUTPUT ${CL_BIN}
59     COMMAND opencl_compiler -output-file ${CL_BIN} ${CL_SRC} -- ${CL_INC} -x clc++
60     MAIN_DEPENDENCY ${CL_SRC}
61 )
62
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})
67
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__")
72
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
78                    )
79
80 # Additional include folders in alphabetical order except ROOT
81 include_directories(${ROOT_INCLUDE_DIRS}
82                     ${AliRoot_SOURCE_DIR}/HLT/BASE
83                     ${AMDAPPSDKROOT}/include
84                    )
85
86 # Sources in alphabetical order
87 set(SRCS
88     ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.cxx
89     AliHLTTPCCAGPUTrackerOpenCL.cxx
90     ${CAGPUDIR}/makefiles/include.S
91    )
92
93 # Headers from sources
94 set(CINTHDRS
95     ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.h
96     AliHLTTPCCAGPUTrackerOpenCL.h
97 )
98
99 set(HDRS
100     ${CINTHDRS}
101     ${CAGPUDIR}/AliHLTTPCCAGPUTrackerCommon.h
102     AliHLTTPCCAGPUTrackerOpenCLInternals.h
103   )
104
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}")
109
110 # Generate the ROOT map
111 generate_rootmap("${MODULE}" "" "")
112
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)
117
118 # Installation
119 install(TARGETS ${MODULE}
120         ARCHIVE DESTINATION lib
121         LIBRARY DESTINATION lib)
122
123 install(FILES ${HDRS} DESTINATION include)