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

Introducing SYCL implementations/variants #64

merged 13 commits into from
Feb 7, 2024

Conversation

MichaelSt98
Copy link
Contributor

variants: SCC, SCC-HOIST, SCC-K-CACHING

Tested on NVIDIA A100 via

  • Intel oneAPI DPC++
    • Getting Started with oneAPI DPC++
    • e.g. using a local installation, /cloudsc-bundle build --clean --cmake='CMAKE_CXX_COMPILER="/home/nams/opt/dpcpp/bin/clang++" CMAKE_CXX_FLAGS="-O3 -L/home/nams/opt/dpcpp/lib -fopenmp -fsycl-early-optimizations -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xcuda-ptxas --maxrregcount=128 -Xsycl-target-backend --cuda-gpu-arch=sm_80 -I/usr/local/apps/intel/2021.4.0/compiler/2021.4.0/linux/compiler/include"' --arch=arch/ecmwf/hpc2020/intel/2021.4.0 --with-gpu --with-sycl --with-serialbox --build-dir=build-sycl
      • need to comment Ktrap=fp in the toolchain file
  • AdpativeCpp (formerly hipSYCL / Open SYCL)

Tested on AMD MI250X (LUMI) via

* 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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like you accidentally dropped the header in this copy-paste. This needs to go back, I think.

Copy link
Collaborator

@mlange05 mlange05 left a comment

Choose a reason for hiding this comment

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

Looks great to me, GTG. :shipit:

Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

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

A few remarks on the CMake integration, please have a look if you think it would make sense to change this. Otherwise good from my side!

bundle.yml Outdated
help: Enable GPU kernel variant based on SYCL
cmake: >
ENABLE_SYCL=ON
ENABLE_CLOUDSC_SYCL=ON
Copy link
Collaborator

Choose a reason for hiding this comment

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

The second is redundant, it should automatically be switched on when SYCL and Serialbox are enabled due to it being DEFAULT ON

@@ -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 )

$<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.

Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

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

Very nicely done and could go in like this from my side! I've tested that build and execution works on AC.
I've left a few recommendations for cleaning up the toolchain, just to avoid carrying around a bunch of redundant stuff.

cloudsc_driver(omp_threads, ngptot, nproma);
}
else {
printf("Calling c-cloudsc with the right number of arguments will work better ;-) \n",argc);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The compiler kindly pointed this out to me:

/etc/ecmwf/nfs/dh1_home_a/nabr/dwarf-p-cloudsc/nams_sycl/source/cloudsc-dwarf/src/cloudsc_sycl/dwarf_cloudsc.cpp:39:91: warning: data argument not used by format string [-Wformat-extra-args]
    printf("Calling c-cloudsc with the right number of arguments will work better ;-) \n",argc);
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
1 warning generated.

Could we change that message to something like the following?

printf("Usage: %s [num_threads ngptot nproma]", argv[0])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes 👍 not the only compiler complaining about this. What do you think about refactoring this for all at a later stage?

arch/toolchains/ecmwf-hpc2020-intel-sycl.cmake Outdated Show resolved Hide resolved
arch/toolchains/ecmwf-hpc2020-intel-sycl.cmake Outdated Show resolved Hide resolved
arch/toolchains/ecmwf-hpc2020-intel-sycl.cmake Outdated Show resolved Hide resolved
Comment on lines +150 to +154
set(CMAKE_CXX_FLAGS "-O3 -L/home/nams/opt/dpcpp/lib -fopenmp -lstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-early-optimizations -fsycl")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xsycl-target-backend --cuda-gpu-arch=sm_80")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/apps/intel/2021.4.0/compiler/2021.4.0/linux/compiler/include")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think since we're now using add_sycl_to_target, the proper way would be to add the relevant ones to SYCL_FLAGS only. But because we're high-jacking the CMake module from a newer installation, I found it tricky to get to work reliably. So, just as an FYI and not necessary to change anything here.

@reuterbal reuterbal merged commit 78f8a49 into develop Feb 7, 2024
16 checks passed
@reuterbal reuterbal deleted the nams_sycl branch February 7, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants