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

CUDA C++ 20 #474

Merged
merged 6 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if(SPH_EXA_WITH_CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
find_package(CUDAToolkit)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD 20)
else()
message(STATUS "No CUDA support")
set(SPH_EXA_WITH_CUDA OFF)
Expand All @@ -64,7 +64,7 @@ if(SPH_EXA_WITH_HIP)
if(CMAKE_HIP_COMPILER AND NOT CMAKE_CUDA_COMPILER)
enable_language(HIP)
find_package(hip)
set(CMAKE_HIP_STANDARD 17)
set(CMAKE_HIP_STANDARD 20)
else()
message(STATUS "No HIP support")
set(SPH_EXA_WITH_HIP OFF)
Expand Down
1 change: 0 additions & 1 deletion ci/cuda12/run_debug_sm90.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ sph-run-cuda12-sm90-debug-1rank:
- sbin/hydro/sph_tests
- sbin/performance/octree_perf
- sbin/performance/peers_perf
- sbin/performance/scan_perf
- sbin/ryoanji/cpu_unit_tests/ryoanji_cpu_unit_tests
- sbin/ryoanji/unit_tests/ryoanji_unit_tests
# TODO:slow - sbin/performance/hilbert_perf
Expand Down
1 change: 0 additions & 1 deletion ci/cuda12/run_release_sm90.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ sph-run-cuda12-sm90-release-1rank:
- sbin/hydro/sph_tests
- sbin/performance/octree_perf
- sbin/performance/peers_perf
- sbin/performance/scan_perf
- sbin/ryoanji/cpu_unit_tests/ryoanji_cpu_unit_tests
- sbin/ryoanji/unit_tests/ryoanji_unit_tests
# TODO:slow - sbin/performance/hilbert_perf
Expand Down
4 changes: 2 additions & 2 deletions domain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if(CSTONE_WITH_CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
find_package(CUDAToolkit)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD 20)
else()
message(STATUS "No CUDA support")
set(CSTONE_WITH_CUDA OFF)
Expand All @@ -52,7 +52,7 @@ if(CSTONE_WITH_HIP)
if(CMAKE_HIP_COMPILER)
enable_language(HIP)
find_package(hip)
set(CMAKE_HIP_STANDARD 17)
set(CMAKE_HIP_STANDARD 20)
else()
message(STATUS "No HIP support")
set(CSTONE_WITH_HIP OFF)
Expand Down
3 changes: 1 addition & 2 deletions domain/LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
MIT License

Copyright (c) 2021 CSCS, ETH Zurich
2021 University of Basel
Copyright (c) 2024 CSCS, ETH Zurich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
24 changes: 4 additions & 20 deletions domain/include/cstone/cuda/annotation.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
/*
* MIT License
* Cornerstone octree
*
* Copyright (c) 2021 CSCS, ETH Zurich
* 2021 University of Basel
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

/*! @file
Expand Down
8 changes: 8 additions & 0 deletions domain/include/cstone/cuda/cub.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Cornerstone octree
*
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

#pragma once

Expand Down
9 changes: 9 additions & 0 deletions domain/include/cstone/cuda/cuda_runtime.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Cornerstone octree
*
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

/*! @file
* @brief CUDA/HIP runtime API compatiblity wrapper
*
Expand Down
26 changes: 5 additions & 21 deletions domain/include/cstone/cuda/cuda_stubs.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
/*
* MIT License
* Cornerstone octree
*
* Copyright (c) 2022 Politechnical University of Catalonia UPC
* 2022 University of Basel
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

/*! @file
Expand Down Expand Up @@ -56,7 +40,7 @@ void memcpyD2D(const T* src, std::size_t n, T* dest);

void syncGpu();

/*! @brief detection trait to determine whether a template parameter is an instance of thrust::device_vector
/*! @brief detection trait to determine whether a template parameter is a device vector
*
* @tparam Vector the Vector type to check
*
Expand Down
9 changes: 9 additions & 0 deletions domain/include/cstone/cuda/cuda_utils.cuh
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Cornerstone octree
*
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

/*! @file
* @brief CUDA runtime API wrapper for compatiblity with CPU code
*
Expand Down
24 changes: 4 additions & 20 deletions domain/include/cstone/cuda/cuda_utils.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
/*
* MIT License
* Cornerstone octree
*
* Copyright (c) 2021 CSCS, ETH Zurich
* 2021 University of Basel
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

#pragma once
Expand Down
9 changes: 9 additions & 0 deletions domain/include/cstone/cuda/device_vector.cu
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Cornerstone octree
*
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

/*! @file
* @brief Encapsulation around a std::vector like GPU-resident device vector, suitable for use in .cpp files
*
Expand Down
9 changes: 9 additions & 0 deletions domain/include/cstone/cuda/device_vector.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Cornerstone octree
*
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

/*! @file
* @brief Encapsulation around a std::vector like GPU-resident device vector, suitable for use in .cpp files
*
Expand Down
23 changes: 4 additions & 19 deletions domain/include/cstone/cuda/errorcheck.cuh
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
/*
* MIT License
* Cornerstone octree
*
* Copyright (c) 2022 CSCS, ETH Zurich
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

#pragma once
Expand Down
24 changes: 4 additions & 20 deletions domain/include/cstone/cuda/gpu_config.cuh
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
/*
* MIT License
* Cornerstone octree
*
* Copyright (c) 2022 CSCS, ETH Zurich
* 2021 University of Basel
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

/*! @file
Expand Down
9 changes: 9 additions & 0 deletions domain/include/cstone/cuda/thrust_util.cuh
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Cornerstone octree
*
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
*/

/*! @file
* @brief Utilities for Thrust device vectors for use in .cu translation units only
*/
Expand Down
18 changes: 9 additions & 9 deletions domain/include/cstone/domain/assignment.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Cornerstone octree
*
* Copyright (c) 2024 CSCS, ETH Zurich, University of Zurich, 2021 University of Basel
* Copyright (c) 2024 CSCS, ETH Zurich
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: MIT License
Expand Down Expand Up @@ -82,18 +82,18 @@ class GlobalAssignment
else { box_ = limitBoxShrinking(fittingBox, box_); }

// compute SFC particle keys only for particles participating in tree build
gsl::span<KeyType> keyView(particleKeys + bufDesc.start, numParticles);
std::span<KeyType> keyView(particleKeys + bufDesc.start, numParticles);
computeSfcKeys(x + bufDesc.start, y + bufDesc.start, z + bufDesc.start, sfcKindPointer(keyView.data()),
numParticles, box_);

// sort keys and keep track of ordering for later use
reorderFunctor.setMapFromCodes(keyView.begin(), keyView.end());
reorderFunctor.setMapFromCodes(keyView);

updateOctreeGlobal(keyView.begin(), keyView.end(), bucketSize_, tree_, nodeCounts_);
updateOctreeGlobal<KeyType>(keyView, bucketSize_, tree_, nodeCounts_);
if (firstCall_)
{
firstCall_ = false;
while (!updateOctreeGlobal(keyView.begin(), keyView.end(), bucketSize_, tree_, nodeCounts_))
while (!updateOctreeGlobal<KeyType>(keyView, bucketSize_, tree_, nodeCounts_))
;
}

Expand Down Expand Up @@ -142,7 +142,7 @@ class GlobalAssignment

auto [newStart, newEnd] = domain_exchange::assignedEnvelope(bufDesc, numPresent(), numAssigned());
LocalIndex envelopeSize = newEnd - newStart;
gsl::span<KeyType> keyView(keys + newStart, envelopeSize);
std::span<KeyType> keyView(keys + newStart, envelopeSize);

auto recvStart = domain_exchange::receiveStart(bufDesc, numPresent(), numAssigned());
auto numRecv = numAssigned() - numPresent();
Expand All @@ -153,7 +153,7 @@ class GlobalAssignment
reorderFunctor.extendMap(shifts, s1);

// sort keys and keep track of the ordering
reorderFunctor.updateMap(keyView.begin(), keyView.end());
reorderFunctor.updateMap(keyView);

return std::make_tuple(newStart, keyView.subspan(numSendDown(), numAssigned()));
}
Expand All @@ -170,11 +170,11 @@ class GlobalAssignment
}

//! @brief read only visibility of the global octree leaves to the outside
gsl::span<const KeyType> treeLeaves() const { return tree_.treeLeaves(); }
std::span<const KeyType> treeLeaves() const { return tree_.treeLeaves(); }
//! @brief the octree, including the internal part
const Octree<KeyType>& octree() const { return tree_; }
//! @brief read only visibility of the global octree leaf counts to the outside
gsl::span<const unsigned> nodeCounts() const { return nodeCounts_; }
std::span<const unsigned> nodeCounts() const { return nodeCounts_; }
//! @brief the global coordinate bounding box
const Box<T>& box() const { return box_; }
//! @brief return the space filling curve rank assignment of the last call to @a assign()
Expand Down
Loading