Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing SYCL implementations/variants #64

Merged
merged 13 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ if ( HAVE_HIP )
find_package(hip REQUIRED)
endif()

ecbuild_add_option( FEATURE SYCL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be linked to a check that SYCL is actually available.

We could do this adding REQUIRED_PACKAGES "IntelSYCL" (see https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2024-0/use-cmake-with-the-compiler.html).

If we want to make this compatible with other SYCL implementations (e.g., whatever OpenSYCL is called these days), we could use this pattern:

find_package(IntelSYCL QUIET)
if(NOT IntelSYCL_FOUND)
    find_package(IntelDPCPP QUIET)
endif()
find_package(AdaptiveCpp QUIET)
ecbuild_add_option( FEATURE SYCL
    DESCRIPTION "SYCL" DEFAULT OFF
    CONDITION IntelSYCL_FOUND OR IntelDPCPP_FOUND OR AdaptiveCpp_FOUND )

DESCRIPTION "SYCL" DEFAULT OFF)

### OpenMP
ecbuild_add_option( FEATURE OMP
DESCRIPTION "OpenMP" DEFAULT ON
Expand Down
5 changes: 5 additions & 0 deletions bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ options :
cmake: >
ENABLE_HIP=ON

- with-sycl :
help: Enable GPU kernel variant based on SYCL
cmake: >
ENABLE_SYCL=ON

- with-mpi :
help : Enable MPI-parallel kernel
cmake : ENABLE_MPI=ON
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ add_subdirectory(cloudsc_python)
add_subdirectory(cloudsc_c)
add_subdirectory(cloudsc_cuda)
add_subdirectory(cloudsc_hip)
add_subdirectory(cloudsc_sycl)
add_subdirectory(cloudsc_gpu)
add_subdirectory(cloudsc_loki)
144 changes: 144 additions & 0 deletions src/cloudsc_sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# (C) Copyright 1988- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

# Define this dwarf variant as an ECBuild feature
ecbuild_add_option( FEATURE CLOUDSC_SYCL
DESCRIPTION "Build the SYCL version CLOUDSC using Serialbox" DEFAULT ON
CONDITION Serialbox_FOUND AND HAVE_SYCL
)

if( HAVE_CLOUDSC_SYCL )

set(LINK_SYCL OFF)
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC")
set(LINK_SYCL ON)
endif()

ecbuild_add_library(
TARGET dwarf-cloudsc-scc-sycl-lib
INSTALL_HEADERS LISTED
SOURCES
cloudsc/yoecldp_c.h
cloudsc/load_state.h
cloudsc/load_state.cpp
cloudsc/cloudsc_c.kernel
cloudsc/cloudsc_driver.h
cloudsc/cloudsc_driver.cpp
cloudsc/cloudsc_validate.h
cloudsc/cloudsc_validate.cpp
cloudsc/mycpu.h
cloudsc/mycpu.cpp
PUBLIC_INCLUDES
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cloudsc>
PUBLIC_LIBS
$<$<BOOL:${LINK_SYCL}>:sycl>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serialbox::Serialbox_C
$<${HAVE_OMP}:OpenMP::OpenMP_C>
)


ecbuild_add_executable(
TARGET dwarf-cloudsc-scc-sycl
SOURCES dwarf_cloudsc.cpp
LIBS dwarf-cloudsc-scc-sycl-lib
)

ecbuild_add_test(
TARGET dwarf-cloudsc-sycl-serial
COMMAND bin/dwarf-cloudsc-scc-sycl
ARGS 1 1000 128
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../..
OMP 1
)

######

ecbuild_add_library(
TARGET dwarf-cloudsc-scc-hoist-sycl-lib
INSTALL_HEADERS LISTED
SOURCES
cloudsc/yoecldp_c.h
cloudsc/load_state.h
cloudsc/load_state.cpp
cloudsc/cloudsc_c_hoist.kernel
cloudsc/cloudsc_driver_hoist.h
cloudsc/cloudsc_driver_hoist.cpp
cloudsc/cloudsc_validate.h
cloudsc/cloudsc_validate.cpp
cloudsc/mycpu.h
cloudsc/mycpu.cpp
PUBLIC_INCLUDES
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cloudsc>
PUBLIC_LIBS
$<$<BOOL:${LINK_SYCL}>:sycl>
Serialbox::Serialbox_C
$<${HAVE_OMP}:OpenMP::OpenMP_C>
)

ecbuild_add_executable(
TARGET dwarf-cloudsc-scc-hoist-sycl
SOURCES dwarf_cloudsc.cpp
LIBS dwarf-cloudsc-scc-hoist-sycl-lib
)

ecbuild_add_test(
TARGET dwarf-cloudsc-sycl-hoist-serial
COMMAND bin/dwarf-cloudsc-scc-hoist-sycl
ARGS 1 1000 128
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../..
OMP 1
)

######

ecbuild_add_library(
TARGET dwarf-cloudsc-scc-k-caching-sycl-lib
INSTALL_HEADERS LISTED
SOURCES
cloudsc/yoecldp_c.h
cloudsc/load_state.h
cloudsc/load_state.cpp
cloudsc/cloudsc_c_k_caching.kernel
cloudsc/cloudsc_driver.h
cloudsc/cloudsc_driver_k_caching.cpp
cloudsc/cloudsc_validate.h
cloudsc/cloudsc_validate.cpp
cloudsc/mycpu.h
cloudsc/mycpu.cpp
PUBLIC_INCLUDES
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cloudsc>
PUBLIC_LIBS
$<$<BOOL:${LINK_SYCL}>:sycl>
Serialbox::Serialbox_C
$<${HAVE_OMP}:OpenMP::OpenMP_C>
)

ecbuild_add_executable(
TARGET dwarf-cloudsc-scc-k-caching-sycl
SOURCES dwarf_cloudsc.cpp
LIBS dwarf-cloudsc-scc-k-caching-sycl-lib
)

ecbuild_add_test(
TARGET dwarf-cloudsc-sycl-k-caching-serial
COMMAND bin/dwarf-cloudsc-scc-k-caching-sycl
ARGS 1 1000 128
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../..
OMP 1
)

# Create symlink for the input data
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/../../data ${CMAKE_CURRENT_BINARY_DIR}/../../../data )

else()
ecbuild_info( "Serialbox not found, disabling SYCL version" )
endif()
Loading