Skip to content

Commit 11a9ecf

Browse files
add thrust/PSTL example with particles and tracks
TODO: includes massive hacks to LLAMA. Using a custom fork of thrust to fix supporting proxy references.
1 parent e5f3c31 commit 11a9ecf

File tree

8 files changed

+779
-14
lines changed

8 files changed

+779
-14
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "examples/raycast/Sponza"]
22
path = examples/raycast/Sponza
33
url = https://github.com/jimmiebergmann/Sponza
4+
[submodule "thirdparty/thrust"]
5+
path = thirdparty/thrust
6+
url = https://github.com/bernhardmgruber/thrust.git

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ if (LLAMA_BUILD_EXAMPLES)
8787
add_subdirectory("examples/bytesplit")
8888
add_subdirectory("examples/bitpackint")
8989
add_subdirectory("examples/bitpackfloat")
90+
add_subdirectory("examples/thrust")
9091

9192
# alpaka examples
9293
find_package(alpaka 0.7.0 QUIET)

examples/thrust/CMakeLists.txt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required (VERSION 3.15)
2+
project(llama-thrust CXX CUDA)
3+
4+
set (Thrust_DIR "../../thirdparty/thrust/thrust/cmake/")
5+
find_package(Thrust REQUIRED CONFIG)
6+
thrust_create_target(Thrust FROM_OPTIONS)
7+
find_package(OpenMP REQUIRED)
8+
if (NOT TARGET llama::llama)
9+
find_package(llama REQUIRED)
10+
endif()
11+
add_executable(${PROJECT_NAME} thrust.cu ../common/Stopwatch.hpp ../common/hostname.hpp)
12+
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
13+
target_compile_options(${PROJECT_NAME} PUBLIC
14+
$<$<COMPILE_LANGUAGE:CUDA>:
15+
-forward-unknown-to-host-compiler
16+
--expt-extended-lambda
17+
--expt-relaxed-constexpr
18+
--use_fast_math
19+
--ftemplate-backtrace-limit 500>)
20+
target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama Thrust OpenMP::OpenMP_CXX)
21+
22+
# OpenMP is not added to the compiler commandline by cmake when using nvcc ..
23+
if (NOT MSVC)
24+
find_package(TBB REQUIRED)
25+
target_link_libraries(${PROJECT_NAME} PRIVATE TBB::tbb)
26+
target_compile_options(${PROJECT_NAME} PUBLIC -march=native -ffast-math -fopenmp)
27+
else()
28+
target_compile_options(${PROJECT_NAME} PUBLIC /openmp)
29+
endif()

0 commit comments

Comments
 (0)