]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
HLT GPU - to be tested
authoragrigora <alina.grigoras@cern.ch>
Wed, 5 Nov 2014 16:24:30 +0000 (17:24 +0100)
committeragrigora <alina.grigoras@cern.ch>
Mon, 15 Dec 2014 12:51:53 +0000 (13:51 +0100)
HLT/CMakeLists.txt
HLT/TPCLib/CMakeLists.txt
HLT/TPCLib/tracking-ca/cagpu/cuda/AliHLTTPCCAGPUTrackerNVCC.cu [moved from HLT/TPCLib/tracking-ca/cagpu/AliHLTTPCCAGPUTrackerNVCC.cu with 100% similarity]
HLT/TPCLib/tracking-ca/cagpu/cuda/AliHLTTPCCAGPUTrackerNVCC.h [moved from HLT/TPCLib/tracking-ca/cagpu/AliHLTTPCCAGPUTrackerNVCC.h with 100% similarity]
HLT/TPCLib/tracking-ca/cagpu/cuda/CMakeLists.txt [new file with mode: 0644]
HLT/TPCLib/tracking-ca/cagpu/opencl/AliHLTTPCCAGPUTrackerOpenCL.cl [moved from HLT/TPCLib/tracking-ca/cagpu/AliHLTTPCCAGPUTrackerOpenCL.cl with 100% similarity]
HLT/TPCLib/tracking-ca/cagpu/opencl/AliHLTTPCCAGPUTrackerOpenCL.cxx [moved from HLT/TPCLib/tracking-ca/cagpu/AliHLTTPCCAGPUTrackerOpenCL.cxx with 100% similarity]
HLT/TPCLib/tracking-ca/cagpu/opencl/AliHLTTPCCAGPUTrackerOpenCL.h [moved from HLT/TPCLib/tracking-ca/cagpu/AliHLTTPCCAGPUTrackerOpenCL.h with 100% similarity]
HLT/TPCLib/tracking-ca/cagpu/opencl/AliHLTTPCCAGPUTrackerOpenCLInternals.h [moved from HLT/TPCLib/tracking-ca/cagpu/AliHLTTPCCAGPUTrackerOpenCLInternals.h with 100% similarity]
HLT/TPCLib/tracking-ca/cagpu/opencl/CMakeLists.txt [new file with mode: 0644]

index 6e59390481206ca1215d2075063996d55ace3b5d..e30b6e867b7db0546c48adf23e90dc5d7fe6549f 100644 (file)
@@ -59,15 +59,4 @@ add_subdirectory(rec)
 add_subdirectory(shuttle)
 add_subdirectory(sim)
 
-
-#file(GLOB PACKAGES CMake*.pkg)
-
-#if(HLT_CUDA)
-#  list(APPEND PACKAGES TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPU.pkg)
-#endif(HLT_CUDA)
-
-#if(HLT_OPENCL)
-#  list(APPEND PACKAGES TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPUOpenCL.pkg)
-#endif()
-
 message(STATUS "HLT enabled")
index 09334803c082aa5d5c9ca30fcfb11ddca862b6e4..b1877da57a7f2a3a81638f8006569ee259695b95 100644 (file)
@@ -21,6 +21,14 @@ if(ROOT_HASOPENGL STREQUAL "yes")
     add_subdirectory(EVE)
 endif()
 
+if(HLT_CUDA)
+    add_subdirectory(tracking-ca/cagpu/cuda)
+endif(HLT_CUDA)
+
+if(HLT_OPENCL)
+    add_subdirectory(tracking-ca/cagpu/opencl)
+endif()
+
 # Module
 set(MODULE AliHLTTPC)
 
diff --git a/HLT/TPCLib/tracking-ca/cagpu/cuda/CMakeLists.txt b/HLT/TPCLib/tracking-ca/cagpu/cuda/CMakeLists.txt
new file mode 100644 (file)
index 0000000..aa2d403
--- /dev/null
@@ -0,0 +1,99 @@
+# **************************************************************************
+# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
+# *                                                                        *
+# * Author: The ALICE Off-line Project.                                    *
+# * Contributors are mentioned in the code where appropriate.              *
+# *                                                                        *
+# * Permission to use, copy, modify and distribute this software and its   *
+# * documentation strictly for non-commercial purposes is hereby granted   *
+# * without fee, provided that the above copyright notice appears in all   *
+# * copies and that both the copyright notice and this permission notice   *
+# * appear in the supporting documentation. The authors make no claims     *
+# * about the suitability of this software for any purpose. It is          *
+# * provided "as is" without express or implied warranty.                  *
+# **************************************************************************
+
+# Module
+set(MODULE AliHLTTPCCAGPU)
+
+find_package(CUDA)
+if(NOT CUDA_FOUND)
+    message( FATAL_ERROR "NVIDIA CUDA package not found. Please install or set HLT_CUDA=OFF" )
+endif(NOT CUDA_FOUND)
+
+#set nvcc flags
+set(CUDA_NVCC_FLAGS --use_fast_math --maxrregcount 64 -O4 -Xptxas -O4 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35)
+
+#for convenience
+set(CAGPUDIR ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu)
+
+#nvcc fails with std=c++11, remove it temporarily
+string(FIND ${CMAKE_CXX_FLAGS} "-std=c++11" STDCXX11FOUND )
+if(STDCXX11FOUND GREATER -1)
+  string(REPLACE "-std=c++11" "-std=c++98" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+endif()
+
+#compile CUDA object file
+cuda_compile(CAGPU_O AliHLTTPCCAGPUTrackerNVCC.cu)
+
+#set it back
+if(STDCXX11FOUND GREATER -1)
+  string ( REPLACE "-std=c++98" "-std=c++11" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
+endif()
+#end of CUDA specific stuff; from here on build usual library
+
+
+# bit of a hack, but otherwise dictionary compilation fails:
+# defines cudaError_t to make it known
+# defines __ROOT__; triggers "ifdef" in source code to circumvent broken cint behaviour with "volatile" keyword
+# not sure why __ROOT__ is used here, could just as well be something else
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/G__AliHLTTPCCAGPU.cxx PROPERTIES COMPILE_DEFINITIONS "cudaError_t=int;__ROOT__")
+
+# Module include folder
+include_directories(${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu/cuda
+                    ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu
+                    ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca
+                   )
+
+# Additional include folders in alphabetical order except ROOT
+include_directories(${ROOT_INCLUDE_DIRS}
+                    ${AliRoot_SOURCE_DIR}/HLT/BASE
+                   )
+
+# Sources in alphabetical order
+set(SRCS
+    ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.cxx
+    ${CAGPU_O}
+   )
+
+# Headers from sources
+set(HDRS
+    ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.h
+    AliHLTTPCCAGPUTrackerNVCC.h
+    AliHLTTPCCAGPUTrackerCommon.h
+  )
+
+# Generate the dictionary
+# It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument
+get_directory_property(incdirs INCLUDE_DIRECTORIES)
+generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
+
+# Generate the ROOT map
+# Dependecies
+set(LIBDEPS ${CUDA_LIBRARIES} cuda)
+generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
+
+# Add a library to the project using the specified source files
+add_library(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)
+#CUDA run-time and driver
+target_link_libraries(${MODULE} ${CUDA_LIBRARIES} cuda)
+
+# Additional compilation flags
+set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS "-O -g")
+
+*# Installation
+install(TARGETS ${MODULE}
+        ARCHIVE DESTINATION lib
+        LIBRARY DESTINATION lib)
+
+install(FILES ${HDRS} DESTINATION include)
\ No newline at end of file
diff --git a/HLT/TPCLib/tracking-ca/cagpu/opencl/CMakeLists.txt b/HLT/TPCLib/tracking-ca/cagpu/opencl/CMakeLists.txt
new file mode 100644 (file)
index 0000000..96c598d
--- /dev/null
@@ -0,0 +1,122 @@
+# **************************************************************************
+# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
+# *                                                                        *
+# * Author: The ALICE Off-line Project.                                    *
+# * Contributors are mentioned in the code where appropriate.              *
+# *                                                                        *
+# * Permission to use, copy, modify and distribute this software and its   *
+# * documentation strictly for non-commercial purposes is hereby granted   *
+# * without fee, provided that the above copyright notice appears in all   *
+# * copies and that both the copyright notice and this permission notice   *
+# * appear in the supporting documentation. The authors make no claims     *
+# * about the suitability of this software for any purpose. It is          *
+# * provided "as is" without express or implied warranty.                  *
+# **************************************************************************
+
+# Module
+set(MODULE AliHLTTPCCAGPUOpenCL)
+
+# AMD APP SDK required for OpenCL tracker; it's using specific
+# extensions (currently) not provided by other vendors.
+# either set cmake variable via "-D$AMDAPPSDKROOT=/path/to/amdappsdkroot"
+# or via environment variable $AMDAPPSDKROOT
+if(NOT AMDAPPSDKROOT)
+    set(AMDAPPSDKROOT $ENV{AMDAPPSDKROOT})
+endif()
+
+if(NOT AMDAPPSDKROOT)
+    message(FATAL_ERROR "AMDAPPSDKROOT not set. Please install AMD APP SDK and set $AMDAPPSDKROOT or disable HLT_OPENCL.")
+endif()
+
+if(NOT "$ENV{GPU_FORCE_64BIT_PTR}" STREQUAL "1")
+    message(FATAL_ERROR "Please set env variable $GPU_FORCE_64BIT_PTR=1, required by HLT OpenCL tracker.")
+endif()
+
+#convenience variables
+set(CAGPUDIR ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu)
+
+# build the OpenCL compile wrapper:
+# -- checks the correct vendor implementation (AMD)
+# -- builds binary code (blob) for the found platform(s)
+add_executable(opencl_compiler ${CAGPUDIR}/makefiles/makefile_opencl_compiler.cpp)
+target_link_libraries(opencl_compiler -L${AMDAPPSDKROOT}/lib/x86_64 amdocl64 OpenCL)
+
+#convenience variables
+set(CL_SRC AliHLTTPCCAGPUTrackerOpenCL.cl )
+set(CL_BIN ${CMAKE_CURRENT_BINARY_DIR}/AliHLTTPCCAGPUTrackerOpenCLCode.bin )
+set(CL_INC
+    -I${AliRoot_SOURCE_DIR}/HLT/BASE 
+    -I${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca
+    -I${CAGPUDIR}
+)
+
+# executes OpenCL compiler wrapper to build binary object
+add_custom_command(
+    OUTPUT ${CL_BIN}
+    COMMAND opencl_compiler -output-file ${CL_BIN} ${CL_SRC} -- ${CL_INC} -x clc++
+    MAIN_DEPENDENCY ${CL_SRC}
+)
+
+# make cmake compile the assembler file
+set_source_files_properties(${CAGPUDIR}/makefiles/include.S PROPERTIES LANGUAGE CXX)
+# add proper dependency on included binary code
+set_source_files_properties(${CAGPUDIR}/makefiles/include.S PROPERTIES OBJECT_DEPENDS ${CL_BIN})
+
+# bit of a hack, but otherwise dictionary compilation fails:
+# defines __ROOT__; triggers "ifdef" in source code to circumvent broken cint behaviour with "volatile" keyword
+# not sure why __ROOT__ is used here, could just as well be something else
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/G__AliHLTTPCCAGPUOpenCL.cxx PROPERTIES COMPILE_DEFINITIONS "__ROOT__")
+
+# Module include folder
+include_directories(${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu/opencl
+                    ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/makefiles
+                    ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca/cagpu
+                    ${AliRoot_SOURCE_DIR}/HLT/TPCLib/tracking-ca
+                   )
+
+# Additional include folders in alphabetical order except ROOT
+include_directories(${ROOT_INCLUDE_DIRS}
+                    ${AliRoot_SOURCE_DIR}/HLT/BASE
+                    ${AMDAPPSDKROOT}/include
+                   )
+
+# Sources in alphabetical order
+set(SRCS
+    ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.cxx
+    AliHLTTPCCAGPUTrackerOpenCL.cxx
+    ${CAGPUDIR}/makefiles/include.S
+   )
+
+# Headers from sources
+set(HDRS
+    ${CAGPUDIR}/AliHLTTPCCAGPUTrackerBase.h
+    ${CAGPUDIR}/AliHLTTPCCAGPUTrackerCommon.h
+    AliHLTTPCCAGPUTrackerOpenCL.h
+    AliHLTTPCCAGPUTrackerOpenCLInternals.h
+  )
+
+# Generate the dictionary
+# It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument
+get_directory_property(incdirs INCLUDE_DIRECTORIES)
+generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
+
+# Generate the ROOT map
+# Dependecies
+set(LIBDEPS ${CUDA_LIBRARIES} cuda)
+generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
+
+# Add a library to the project using the specified source files
+add_library(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)
+#CUDA run-time and driver
+link_directories(${AMDAPPSDKROOT}/lib/x86_64)
+target_link_libraries(amdocl64 OpenCL)
+
+# Additional compilation flags
+set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS "-O -g")
+
+*# Installation
+install(TARGETS ${MODULE}
+        ARCHIVE DESTINATION lib
+        LIBRARY DESTINATION lib)
+
+install(FILES ${HDRS} DESTINATION include)
\ No newline at end of file