Skip to content

Commit 449c0a5

Browse files
Robadobptheywood
authored andcommitted
Upgrade Jitify to jitify2
- Adds nvjitlink as a CUDA requirement to CI - Borrow Jitify1 demangle for gcc - Prevent jitify2::KernelData from being destroyed after context. - Preload FLAMEGPU headers - This only reduces time from 6.8s to 4.1s (Windows/CUDA 12.0) and can't easily extend it to system headers. - Split up program load so we can serialise linked program. - Quick windows test shows it to be much faster to deserialize. - Specify -D_FILE_OFFSET_BITS=64 for when required for Jitify2 via try_compile - Remove getKnownHeaders() - Disables Werror from some CI workflows - Add compile error string to exception - Jitify2: pin the commit to the HEAD of the jitify2 branch from August 2025, including nodiscard fix - CMake: Specify the jitify2 include directory as SYSTEM to attempt warning suppression on windows - Either JITIFY_VERBOSE_ERRORS must be defined to a truthy value, or .info() must be called on the ErrorMsg for the header log to be included. - see jitify2::make_compilation_error_msg for the implementation - Readme: Remove the known issue about RTC performance for CUDA >= 12.2 - CMake: apply jitify2#146 patches prior to it being merged Co-authored-by Robert Chisholm <r.chisholm@sheffield.ac.uk> Co-authored-by Peter Heywood <p.heywood@sheffield.ac.uk>
1 parent 11b7491 commit 449c0a5

26 files changed

Lines changed: 1459 additions & 207 deletions

.github/scripts/install_cuda_centos.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CUDA_PACKAGES_IN=(
1818
"cuda-nvtx"
1919
"cuda-nvrtc-devel"
2020
"libcurand-devel" # 11-0+
21+
"libnvjitlink-devel" # 12.0+
2122
)
2223

2324
## -------------------
@@ -91,9 +92,12 @@ do :
9192
if [[ ${package} == libcu* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "11.0" ; then
9293
package="${package/libcu/cuda-cu}"
9394
fi
94-
# CUDA < 11, -devel- packages were actually -dev
95-
if [[ ${package} == *devel* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "11.0" ; then
96-
package="${package//devel/dev}"
95+
# libnvjitlink not required prior to CUDA 12.0
96+
if [[ ${package} == libnvjitlink-dev* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "12.0" ;then
97+
continue
98+
# CUDA 11+ includes lib* / lib*-dev packages, which if they existed previously where cuda-cu*- / cuda-cu*-dev-
99+
elif [[ ${package} == lib* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "11.0" ; then
100+
package="${package/libcu/cuda-cu}"
97101
fi
98102
# Build the full package name and append to the string.
99103
CUDA_PACKAGES+=" ${package}-${CUDA_MAJOR}-${CUDA_MINOR}"

.github/scripts/install_cuda_el8.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CUDA_PACKAGES_IN=(
1818
"cuda-nvtx"
1919
"cuda-nvrtc-devel"
2020
"libcurand-devel" # 11-0+
21+
"libnvjitlink-devel" #12-0+
2122
)
2223

2324
## -------------------
@@ -90,6 +91,10 @@ do :
9091
if [[ ${package} == libcu* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "11.0" ; then
9192
package="${package/libcu/cuda-cu}"
9293
fi
94+
# libnvjitlink not required prior to CUDA 12.0
95+
if [[ ${package} == libnvjitlink-dev* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "12.0" ;then
96+
continue
97+
fi
9398
# CUDA < 11, -devel- packages were actually -dev
9499
if [[ ${package} == *devel* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "11.0" ; then
95100
package="${package//devel/dev}"

.github/scripts/install_cuda_ubuntu.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ CUDA_PACKAGES_IN=(
1414
"cuda-nvtx"
1515
"cuda-nvrtc-dev"
1616
"libcurand-dev" # 11-0+
17-
"cuda-cccl" # 11.4+, provides cub and thrust. On 11.3 knwon as cuda-thrust-11-3
17+
"cuda-cccl" # 11.4+, provides cub and thrust. On 11.3 known as cuda-thrust-11-3
18+
"libnvjitlink-dev" # 12.0+
1819
)
1920

2021
## -------------------
@@ -104,8 +105,11 @@ do :
104105
continue
105106
fi
106107
fi
108+
# libnvjitlink not required prior to CUDA 12.0
109+
if [[ ${package} == libnvjitlink-dev* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "12.0" ;then
110+
continue
107111
# CUDA 11+ includes lib* / lib*-dev packages, which if they existed previously where cuda-cu*- / cuda-cu*-dev-
108-
if [[ ${package} == libcu* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "11.0" ; then
112+
elif [[ ${package} == lib* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "11.0" ; then
109113
package="${package/libcu/cuda-cu}"
110114
fi
111115
# Build the full package name and append to the string.

.github/scripts/install_cuda_windows.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ $VISUAL_STUDIO_MIN_CUDA = @{
6868
"2022" = "11.6.0";
6969
"2019" = "10.1";
7070
"2017" = "10.0"; # Depends on which version of 2017! 9.0 to 10.0 depending on version
71-
"2015" = "8.0"; # Might support older, unsure. Depracated as of 11.1, unsupported in 11.2
71+
"2015" = "8.0"; # Might support older, unsure. Deprecated as of 11.1, unsupported in 11.2
7272
}
7373

7474
# cuda_runtime.h is in nvcc <= 10.2, but cudart >= 11.0
@@ -80,6 +80,8 @@ $CUDA_PACKAGES_IN = @(
8080
"nvrtc_dev";
8181
"cudart";
8282
"thrust";
83+
"thrust";
84+
"nvjitlink";
8385
)
8486

8587
## -------------------
@@ -132,6 +134,9 @@ Foreach ($package in $CUDA_PACKAGES_IN) {
132134
} elseif($package -eq "thrust" -and [version]$CUDA_VERSION_FULL -lt [version]"11.3") {
133135
# Thrust is a package from CUDA 11.3, otherwise it should be skipped.
134136
continue
137+
} elseif($package -eq "nvjitlink" -and [version]$CUDA_VERSION_FULL -lt [version]"12.0") {
138+
# nvjitlink is a from CUDA 12.0, otherwise it should be skipped.
139+
continue
135140
}
136141
$CUDA_PACKAGES += " $($package)_$($CUDA_MAJOR).$($CUDA_MINOR)"
137142
}
@@ -180,7 +185,7 @@ while (-not $downloaded) {
180185
Write-Output "Downloading Complete"
181186
$downloaded=$true
182187
} else {
183-
# If downlaod failed, either wait and try again, or give up and error.
188+
# If download failed, either wait and try again, or give up and error.
184189
if ($download_attempt -le $download_attempts_max) {
185190
Write-Output "Error: Failed to download $($CUDA_REPO_PKG_LOCAL) (attempt $($download_attempt)/$($download_attempts_max)). Retrying."
186191
# Sleep for a number of seconds.

.github/workflows/Draft-Release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ jobs:
282282
run: >
283283
cmake . -B "${{ env.BUILD_DIR }}"
284284
-G "${{ env.HOSTCXX }}" -A x64
285-
-Werror=dev
286285
-DCMAKE_WARN_DEPRECATED="OFF"
287286
-DFLAMEGPU_WARNINGS_AS_ERRORS="ON"
288287
-DCMAKE_CUDA_ARCHITECTURES="${{ env.CUDA_ARCH }}"
@@ -585,7 +584,6 @@ jobs:
585584
run: >
586585
cmake . -B "${{ env.BUILD_DIR }}"
587586
-G "${{ env.HOSTCXX }}" -A x64
588-
-Werror=dev
589587
-DCMAKE_WARN_DEPRECATED="OFF"
590588
-DFLAMEGPU_WARNINGS_AS_ERRORS="ON"
591589
-DCMAKE_CUDA_ARCHITECTURES="${{ env.CUDA_ARCH }}"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,3 @@ For a full list of known issues pleases see the [Issue Tracker](https://github.c
373373
374374
+ Warnings and a loss of performance due to hash collisions in device code ([#356](https://github.com/FLAMEGPU/FLAMEGPU2/issues/356))
375375
+ Multiple known areas where performance can be improved (e.g. [#449](https://github.com/FLAMEGPU/FLAMEGPU2/issues/449), [#402](https://github.com/FLAMEGPU/FLAMEGPU2/issues/402))
376-
+ CUDA 12.2+ suffers from poor RTC compilation times, to be fixed in a future release ([#1118](https://github.com/FLAMEGPU/FLAMEGPU2/issues/1118)).

cmake/CheckCompilerFunctionality.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,25 @@ function(flamegpu_check_compiler_functionality)
187187
endif()
188188
endif()
189189

190+
if (NOT MSVC)
191+
# Jitify2 on linux requires uses F_OFD_SETLKW or -D_FILE_OFFSET_BITS=64.
192+
# Cannot detect the presence of this from CMAKE_SYSTEM_VERSION when in a container, so try to compile with it and if an error occurs then we must define this option.
193+
# If required, sets a cmake cache internal variable FLAMEGPU__FILE_OFFSET_BITS_64_REQUIRED to true
194+
try_compile(
195+
LINUX_F_OFD_SETLKW
196+
"${CMAKE_CURRENT_BINARY_DIR}/try_compile"
197+
"${CMAKE_CURRENT_LIST_DIR}/CheckCompilerFunctionality/F_OFD_SETLKW.cpp"
198+
CXX_STANDARD 17
199+
CUDA_STANDARD 17
200+
CXX_STANDARD_REQUIRED "ON"
201+
)
202+
if(NOT LINUX_F_OFD_SETLKW)
203+
set(FLAMEGPU__FILE_OFFSET_BITS_64_REQUIRED "true" CACHE INTERNAL "if _FILE_OFFSET_BITS=64 required for jitify2")
204+
else()
205+
set(FLAMEGPU__FILE_OFFSET_BITS_64_REQUIRED "false" CACHE INTERNAL "if _FILE_OFFSET_BITS=64 required for jitify2")
206+
endif()
207+
endif()
208+
190209
# If we made it this far, set the result variable to be truthy
191210
set(FLAMEGPU_CheckCompilerFunctionality_RESULT "YES" PARENT_SCOPE)
192211
endfunction()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifdef __linux__
2+
#include <fcntl.h>
3+
#endif // __linux__
4+
5+
int main (int argc, char * argv[]) {
6+
#ifndef F_OFD_SETLKW
7+
#error F_OFD_SETLKW is not defined; try building with -D_FILE_OFFSET_BITS=64
8+
#endif // F_OFD_SETLKW
9+
return 0;
10+
}

cmake/dependencies/Jitify.cmake

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,48 @@ endif()
1414
FetchContent_Declare(
1515
jitify
1616
GIT_REPOSITORY https://github.com/NVIDIA/jitify.git
17-
GIT_TAG 9c01f4988bbc3e11fcb84fc2747b5d0f2af7862e
17+
GIT_TAG 44e978b21fc8bdb6b2d7d8d179523c8350db72e5 # jitify2 branch on 2025-08-23, pre windows patches
1818
SOURCE_DIR ${FETCHCONTENT_BASE_DIR}/jitify-src/jitify
1919
GIT_PROGRESS ON
2020
# UPDATE_DISCONNECTED ON
2121
)
2222
FetchContent_GetProperties(jitify)
2323
if(NOT jitify_POPULATED)
2424
FetchContent_Populate(jitify)
25-
# Jitify is not a cmake project, so cannot use add_subdirectory, use custom find_package.
25+
# Apply patches to jitify2 for msvc support prior to https://github.com/NVIDIA/jitify/pull/146 being merged
26+
# patch generated from jitify fork/branch, via `git format-patch jitify2 --stdout > jitify2-pr-146.patch`
27+
# Does not use fetch content PATCH_COMMAND as it was unreliable / problematic on windows for prior rapidjson patching
28+
# This will silently not apply the patch if it is not applicable, which supports repeated fetching but may lead to silent failures
29+
# Check if the patch is applicable
30+
execute_process(
31+
COMMAND git apply --check ${CMAKE_CURRENT_LIST_DIR}/patches/jitify2-pr-146.patch
32+
WORKING_DIRECTORY "${jitify_SOURCE_DIR}"
33+
RESULT_VARIABLE jitify_patch_check_result
34+
OUTPUT_QUIET
35+
ERROR_QUIET
36+
)
37+
# If applicable, apply the patch
38+
if (jitify_patch_check_result EQUAL 0)
39+
message(CHECK_START "Patching jitify #146")
40+
execute_process(
41+
COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/patches/jitify2-pr-146.patch
42+
WORKING_DIRECTORY "${jitify_SOURCE_DIR}"
43+
RESULT_VARIABLE jifity_patch_apply_result
44+
OUTPUT_QUIET
45+
ERROR_QUIET
46+
)
47+
# If the patch failed emit a warning but allow cmake to progress. This should not occur given the previous check.
48+
if (jifity_patch_apply_result EQUAL 0)
49+
message(CHECK_PASS "done")
50+
else()
51+
message(CHECK_FAIL "patching failed")
52+
endif()
53+
unset(jifity_patch_apply_result)
54+
endif()
55+
unset(jitify_patch_check_result)
2656
endif()
2757

58+
# Jitify is not a cmake project, so cannot use add_subdirectory, use custom find_package.
2859
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${jitify_SOURCE_DIR}/..")
2960
# Always find the package, even if jitify is already populated.
3061
find_package(Jitify REQUIRED)

cmake/dependencies/flamegpu2-visualiser.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (FLAMEGPU_VISUALISATION_ROOT)
4242
set(FLAMEGPU_VISUALISATION_ROOT "${FLAMEGPU_VISUALISATION_ROOT_ABS}" PARENT_SCOPE)
4343
# And set up the visualisation build
4444
add_subdirectory(${FLAMEGPU_VISUALISATION_ROOT_ABS} ${CMAKE_CURRENT_BINARY_DIR}/_deps/flamegpu_visualiser-build EXCLUDE_FROM_ALL)
45-
# Set the cahce var too, to ensure it appears in the GUI.
45+
# Set the cache var too, to ensure it appears in the GUI.
4646
set(FLAMEGPU_VISUALISATION_ROOT "${FLAMEGPU_VISUALISATION_ROOT}" CACHE STRING "Path to local copy of the FLAMEGPU2-visualiser repository, rather than CMake-based fetching")
4747

4848
else()

0 commit comments

Comments
 (0)