Skip to content

Commit

Permalink
Introduced vecmem_setup_sycl(...).
Browse files Browse the repository at this point in the history
Exactly as vecmem_setup_core(...), it is meant to set up
the public flags for vecmem::sycl. Such that they could be
(re-)evaluated in the context of the client project.
  • Loading branch information
krasznaa committed Sep 9, 2024
1 parent bc66cae commit 63f7ab0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 16 deletions.
4 changes: 4 additions & 0 deletions cmake/vecmem-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ unset( vecmem_REQUIRED_LIBS )
# (Post-)Configure the targets.
include( vecmem-setup-core )
vecmem_setup_core( vecmem::core )
if( TARGET vecmem::sycl )
include( vecmem-setup-sycl )
vecmem_setup_sycl( vecmem::sycl )
endif()
22 changes: 6 additions & 16 deletions sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,12 @@ if( VECMEM_HAVE_SYCL_MEMSET )
target_compile_definitions( vecmem_sycl PRIVATE VECMEM_HAVE_SYCL_MEMSET )
endif()

# Check if sycl::local_accessor is available.
vecmem_check_sycl_source_compiles( "
#include <CL/sycl.hpp>
int main() {
cl::sycl::queue queue;
queue.submit([](cl::sycl::handler& h) {
cl::sycl::local_accessor<int> dummy(10, h);
(void)dummy;
}).wait_and_throw();
return 0;
}
" VECMEM_HAVE_SYCL_LOCAL_ACCESSOR )
if( VECMEM_HAVE_SYCL_LOCAL_ACCESSOR )
target_compile_definitions( vecmem_sycl INTERFACE
VECMEM_HAVE_SYCL_LOCAL_ACCESSOR )
endif()
# Set up the public definitions for vecmem::sycl, which require configuration
# tests to be made with the C++/SYCL/etc. compilers.
include( "cmake/vecmem-setup-sycl.cmake" )
vecmem_setup_sycl( vecmem_sycl )
install( FILES "cmake/vecmem-setup-sycl.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" )

# Test the public headers of vecmem::sycl.
if( BUILD_TESTING AND VECMEM_BUILD_TESTING )
Expand Down
45 changes: 45 additions & 0 deletions sycl/cmake/vecmem-setup-sycl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# VecMem project, part of the ACTS project (R&D line)
#
# (c) 2024 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

# VecMem include(s).
include( vecmem-check-language )
include( vecmem-check-sycl-source-compiles )

# CMake include(s).
include( CheckCXXSourceCompiles )

# Helper function setting up the public definitions for vecmem::sycl
#
# Usage: vecmem_setup_sycl( vecmem::sycl )
#
function( vecmem_setup_sycl libName )

# Check if a SYCL compiler is available.
vecmem_check_language( SYCL )

# Set the SYCL definitions only if the build system knows about SYCL.
if( CMAKE_SYCL_COMPILER )

# Check if sycl::local_accessor is available.
vecmem_check_sycl_source_compiles( "
#include <CL/sycl.hpp>
int main() {
cl::sycl::queue queue;
queue.submit([](cl::sycl::handler& h) {
cl::sycl::local_accessor<int> dummy(10, h);
(void)dummy;
}).wait_and_throw();
return 0;
}
" VECMEM_HAVE_SYCL_LOCAL_ACCESSOR )
if( VECMEM_HAVE_SYCL_LOCAL_ACCESSOR )
target_compile_definitions( ${libName} INTERFACE
$<BUILD_INTERFACE:VECMEM_HAVE_SYCL_LOCAL_ACCESSOR> )
endif()

endif()

endfunction( vecmem_setup_sycl )

0 comments on commit 63f7ab0

Please sign in to comment.