FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow multiple bitcode targets in COMPUTECPP_BITCODE · codeplaysoftware/computecpp-sdk@1d3b890 · GitHub

This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Repository navigation

Commit 1d3b890

Browse files
authored andcommitted
Allow multiple bitcode targets in COMPUTECPP_BITCODE
Adds support for setting multiple values in COMPUTECPP_BITCODE. When using ComputeCpp Professional Edition this allows multiple versions of the same kernel to be available in the same binary. Display the compiler output when the compiler check fails. This will give the a better error message to the user. `get_sycl_target_extension` takes care of setting the filename extension. Added some documentation.
1 parent f1f1283 commit 1d3b890

4 files changed

Lines changed: 27 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ Lastly, the SDK will build targeting `spir64` IR by default. This will
9191
work on most devices, but won’t work on NVIDIA (for example). To that
9292
end, you can specify `-DCOMPUTECPP_BITCODE=target`, which can be any of
9393
`spir[64]`, `spirv[64]` or `ptx64`.
94+
It is possible to specify multiple targets to `COMPUTECPP_BITCODE`,
95+
as a CMake list.
96+
Note that only the Professional Edition of ComputeCpp
97+
supports building multiple device targets.
9498

9599
If you would like to crosscompile the SDK targeting some other platform,
96100
there are toolchain files available in the cmake/toolchains directory.

‎cmake/Modules/ComputeCppCompilerChecks.cmake‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(MSVC)
2626
COMMAND ${_stl_test_command}
2727
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
2828
RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT
29-
ERROR_QUIET
29+
ERROR_VARIABLE ComputeCpp_STL_CHECK_ERROR_OUTPUT
3030
OUTPUT_QUIET)
3131
if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0)
3232
# Try disabling compiler version checks
@@ -35,7 +35,7 @@ if(MSVC)
3535
-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH
3636
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
3737
RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT
38-
ERROR_QUIET
38+
ERROR_VARIABLE ComputeCpp_STL_CHECK_ERROR_OUTPUT
3939
OUTPUT_QUIET)
4040
if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0)
4141
# Try again with __CUDACC__ and _HAS_CONDITIONAL_EXPLICIT=0. This relaxes the restritions in the MSVC headers
@@ -46,11 +46,12 @@ if(MSVC)
4646
-D__CUDACC__
4747
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
4848
RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT
49-
ERROR_QUIET
49+
ERROR_VARIABLE ComputeCpp_STL_CHECK_ERROR_OUTPUT
5050
OUTPUT_QUIET)
5151
if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0)
5252
message(FATAL_ERROR "compute++ cannot consume hosted STL headers. This means that compute++ can't \
53-
compile a simple program in this platform and will fail when used in this system.")
53+
compile a simple program in this platform and will fail when used in this system. \
54+
\n ${ComputeCpp_STL_CHECK_ERROR_OUTPUT}")
5455
else()
5556
list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH
5657
-D_HAS_CONDITIONAL_EXPLICIT=0

‎cmake/Modules/ComputeCppIRMap.cmake‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,13 @@ set(IR_MAP_custom-spirv64 spv)
1616
set(IR_MAP_custom-spirv32 spv)
1717
set(IR_MAP_ptx64 s)
1818
set(IR_MAP_amdgcn s)
19+
20+
# Retrieves the filename extension of the IR output of compute++
21+
function(get_sycl_target_extension output)
22+
set(syclExtension ${IR_MAP_${COMPUTECPP_BITCODE}})
23+
if(NOT syclExtension)
24+
# Needed when using multiple device targets
25+
set(syclExtension "bc")
26+
endif()
27+
set(${output} ${syclExtension} PARENT_SCOPE)
28+
endfunction()

‎cmake/Modules/FindComputeCpp.cmake‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ separate_arguments(COMPUTECPP_USER_FLAGS)
3838
mark_as_advanced(COMPUTECPP_USER_FLAGS)
3939

4040
set(COMPUTECPP_BITCODE "spir64" CACHE STRING
41-
"Bitcode type to use as SYCL target in compute++")
41+
"Bitcode types to use as SYCL targets in compute++.")
4242
mark_as_advanced(COMPUTECPP_BITCODE)
4343

4444
set(SYCL_LANGUAGE_VERSION "2017" CACHE STRING "SYCL version to use. Defaults to 1.2.1.")
@@ -153,8 +153,12 @@ if(CMAKE_CROSSCOMPILING)
153153
list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -target ${COMPUTECPP_TARGET_TRIPLE})
154154
endif()
155155

156-
list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -sycl-target ${COMPUTECPP_BITCODE})
157156
list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -DSYCL_LANGUAGE_VERSION=${SYCL_LANGUAGE_VERSION})
157+
158+
foreach (bitcode IN ITEMS ${COMPUTECPP_BITCODE})
159+
list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -sycl-target ${bitcode})
160+
endforeach()
161+
158162
message(STATUS "compute++ flags - ${COMPUTECPP_DEVICE_COMPILER_FLAGS}")
159163

160164
include(ComputeCppCompilerChecks)
@@ -238,7 +242,8 @@ function(__build_ir)
238242
# using the same source file will be generated with a different rule.
239243
set(baseSyclName ${CMAKE_CURRENT_BINARY_DIR}/${SDK_BUILD_IR_TARGET}_${sourceFileName})
240244
set(outputSyclFile ${baseSyclName}.sycl)
241-
set(outputDeviceFile ${baseSyclName}.${IR_MAP_${COMPUTECPP_BITCODE}})
245+
get_sycl_target_extension(targetExtension)
246+
set(outputDeviceFile ${baseSyclName}.${targetExtension})
242247
set(depFileName ${baseSyclName}.sycl.d)
243248

244249
set(include_directories "$<TARGET_PROPERTY:${SDK_BUILD_IR_TARGET},INCLUDE_DIRECTORIES>")

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL