-
Notifications
You must be signed in to change notification settings - Fork 20
Spatter HIP #246
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
Merged
Merged
Spatter HIP #246
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e4c7a77
Initial commit for full rewrite
8277284
Cleaned out old testing files
96b357f
Normalize file permissions
a0be452
Cleaned up more file permissions, and small changes to a few other files
dff5f3d
Updated device synch on multi-launch scatter and fixed include statemnts
a2cb119
fix merge conflicts
plavin 66b6740
disable HIP by default
plavin 2f8041d
rearrage cpu tests
plavin af22565
fix spelling
plavin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,39 @@ | ||
| # CMakeLists.txt | ||
| cmake_minimum_required(VERSION 3.25) | ||
|
|
||
| set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) | ||
|
|
||
| include(DisableIntree) | ||
|
|
||
| project(Spatter VERSION 2.0.0 LANGUAGES CXX) | ||
| option(USE_CUDA "Enable CUDA support" OFF) | ||
| option(USE_HIP "Enable HIP support" ON) | ||
|
|
||
| if(USE_CUDA AND USE_HIP) | ||
| message(FATAL_ERROR "Cannot enable both CUDA and HIP simultaneously. Choose one.") | ||
| endif() | ||
|
|
||
| if(USE_HIP) | ||
| if(NOT DEFINED CMAKE_CXX_COMPILER) | ||
| set(CMAKE_CXX_COMPILER "hipcc" CACHE STRING "HIP C++ Compiler" FORCE) | ||
| endif() | ||
| project(Spatter VERSION 2.0.0 LANGUAGES CXX HIP) | ||
| include(pkgs/HIPSupport) | ||
| else() | ||
| project(Spatter VERSION 2.0.0 LANGUAGES CXX) | ||
| if(USE_CUDA) | ||
| include(pkgs/CUDASupport) | ||
| endif() | ||
| endif() | ||
|
|
||
| include(GNUInstallDirs) | ||
|
|
||
| include(BuildType) | ||
| include(CompilerType) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED on) | ||
|
|
||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| include(pkgs/JSONSupport) | ||
| include(pkgs/MPISupport) | ||
| include(pkgs/OpenMPSupport) | ||
| include(pkgs/CUDASupport) | ||
|
|
||
| # Create gz_read executable | ||
| add_executable(gz_read standard-suite/binary-traces/gz_read.cc) | ||
| target_link_libraries(gz_read z) | ||
|
|
||
| add_subdirectory(src) | ||
|
|
||
| enable_testing() | ||
| add_subdirectory(tests) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # cmake/FindHIP.cmake | ||
| if(NOT DEFINED HIP_PATH) | ||
| message(STATUS "HIP_PATH not defined; trying to locate hipcc in PATH.") | ||
| find_program(HIPCC_EXECUTABLE NAMES hipcc) | ||
| else() | ||
| set(HIPCC_EXECUTABLE "${HIP_PATH}/bin/hipcc") | ||
| endif() | ||
|
|
||
| if(NOT HIPCC_EXECUTABLE) | ||
| message(FATAL_ERROR "hipcc not found. Please ensure HIP is installed and/or set HIP_PATH to the HIP installation root.") | ||
| endif() | ||
|
|
||
| get_filename_component(HIP_BIN_DIR "${HIPCC_EXECUTABLE}" DIRECTORY) | ||
| get_filename_component(HIP_ROOT "${HIP_BIN_DIR}" DIRECTORY) | ||
|
|
||
| set(HIP_INCLUDE_DIRS "${HIP_ROOT}/include") | ||
| set(HIP_LIBRARIES "hip") | ||
|
|
||
| if(NOT EXISTS "${HIP_INCLUDE_DIRS}/hip/hip_runtime.h") | ||
| message(WARNING "Expected HIP header not found at ${HIP_INCLUDE_DIRS}/hip/hip_runtime.h. " | ||
| "If hipcc is in /usr/bin, then HIP_ROOT is set to ${HIP_ROOT}. " | ||
| "This may not be the actual HIP installation directory. " | ||
| "Consider setting -DHIP_PATH to the correct HIP installation root.") | ||
| endif() | ||
|
|
||
| set(HIP_FOUND TRUE) | ||
| set(HIP_CONFIG_VERSION "0.0.1") | ||
|
|
||
| message(STATUS "Found HIP installation at: ${HIP_ROOT}") | ||
| message(STATUS "HIP include directories: ${HIP_INCLUDE_DIRS}") | ||
| message(STATUS "HIP libraries: ${HIP_LIBRARIES}") | ||
|
|
||
| mark_as_advanced(HIP_INCLUDE_DIRS HIP_LIBRARIES HIP_ROOT) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| option(USE_HIP "Enable support for HIP" ON) | ||
|
|
||
| if (USE_HIP) | ||
| if(NOT DEFINED HIP_PATH) | ||
| set(HIP_PATH "/opt/rocm-6.3.1") | ||
| endif() | ||
|
|
||
| list(APPEND CMAKE_PREFIX_PATH "${HIP_PATH}/lib/cmake") | ||
|
|
||
| find_package(hip REQUIRED CONFIG) | ||
|
|
||
| if (hip_FOUND) | ||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
|
||
| add_definitions(-DUSE_HIP) | ||
|
|
||
| set(COMMON_LINK_LIBRARIES ${COMMON_LINK_LIBRARIES} | ||
| hip::device | ||
| amdhip64 | ||
| ) | ||
|
|
||
| message(STATUS "HIP support enabled.") | ||
| message(STATUS "HIP path: ${HIP_PATH}") | ||
| message(STATUS "HIP version: ${hip_VERSION}") | ||
| else() | ||
| message(FATAL_ERROR "HIP not found") | ||
| endif() | ||
| else() | ||
| message(STATUS "HIP support disabled") | ||
| endif() |
Empty file.
Empty file.
Empty file modified
0
results/v0.2/gather/cuda/v100/sg_sparse_roofline_cuda_oded-v100_GATHER.ssv
100755 → 100644
Empty file.
Empty file modified
0
results/v0.2/scatter/cuda/v100/sg_sparse_roofline_cuda_oded-v100_SCATTER.ssv
100755 → 100644
Empty file.
Empty file modified
0
results/v0.2/sg/cuda/v100/sg_sparse_roofline_cuda_oded-v100_SG.ssv
100755 → 100644
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,18 @@ | ||
| # Spatter/src/CMakeLists.txt | ||
|
|
||
| add_subdirectory(Spatter) | ||
|
|
||
| add_executable(spatter main.cc) | ||
| #target_compile_options(spatter PUBLIC "-fnew-alignment 32") | ||
|
|
||
| if(USE_HIP) | ||
| target_compile_definitions(spatter PRIVATE USE_HIP) | ||
| endif() | ||
| if(USE_CUDA) | ||
| target_compile_definitions(spatter PRIVATE USE_CUDA) | ||
| endif() | ||
|
|
||
| target_link_libraries(spatter ${COMMON_LINK_LIBRARIES} Spatter) | ||
|
|
||
| set_target_properties(spatter PROPERTIES | ||
| COMPILE_DEFINITIONS "${COMMON_COMPILE_DEFINITIONS}" | ||
| COMPILE_OPTIONS "${WARNING_FLAGS}" | ||
| RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" | ||
| ) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| #include <cstdint> | ||
| #include <iostream> | ||
| #include <vector> | ||
|
|
||
| /** | ||
| * Allocator for aligned data. | ||
| * Adapted from Stephan T. Lavavej. | ||
| * <http://blogs.msdn.com/b/vcblog/archive/2008/08/28/the-mallocator.aspx> | ||
| */ | ||
|
|
||
| template <typename T, std::size_t Alignment> class aligned_allocator { | ||
| public: | ||
| // The following will be the same for virtually all allocators. | ||
| typedef T *pointer; | ||
| typedef const T *const_pointer; | ||
| typedef T &reference; | ||
| typedef const T &const_reference; | ||
| typedef T value_type; | ||
| typedef std::size_t size_type; | ||
| typedef ptrdiff_t difference_type; | ||
|
|
||
| T *address(T &r) const { return &r; } | ||
|
|
||
| const T *address(const T &s) const { return &s; } | ||
|
|
||
| std::size_t max_size() const { | ||
| // The following has been carefully written to be independent of | ||
| // the definition of size_t and to avoid signed/unsigned warnings. | ||
| return (static_cast<std::size_t>(0) - static_cast<std::size_t>(1)) / | ||
| sizeof(T); | ||
| } | ||
|
|
||
| // The following must be the same for all allocators. | ||
| template <typename U> struct rebind { | ||
| typedef aligned_allocator<U, Alignment> other; | ||
| }; | ||
|
|
||
| bool operator!=(const aligned_allocator &other) const { | ||
| return !(*this == other); | ||
| } | ||
|
|
||
| void construct(T *const p, const T &t) const { | ||
| void *const pv = static_cast<void *>(p); | ||
|
|
||
| new (pv) T(t); | ||
| } | ||
|
|
||
| void destroy(T *const p) const { p->~T(); } | ||
|
|
||
| // Returns true if and only if storage allocated from *this | ||
| // can be deallocated from other, and vice versa. | ||
| // Always returns true for stateless allocators. | ||
| bool operator==(const aligned_allocator &) const { return true; } | ||
|
|
||
| // Default constructor, copy constructor, rebinding constructor, and | ||
| // destructor. Empty for stateless allocators. | ||
| aligned_allocator() {} | ||
|
|
||
| aligned_allocator(const aligned_allocator &) {} | ||
|
|
||
| template <typename U> | ||
| aligned_allocator(const aligned_allocator<U, Alignment> &) {} | ||
|
|
||
| ~aligned_allocator() {} | ||
|
|
||
| // The following will be different for each allocator. | ||
| T *allocate(const std::size_t n) const { | ||
| // The return value of allocate(0) is unspecified. | ||
| // Mallocator returns NULL in order to avoid depending | ||
| // on malloc(0)'s implementation-defined behavior | ||
| // (the implementation can define malloc(0) to return NULL, | ||
| // in which case the bad_alloc check below would fire). | ||
| // All allocators can return NULL in this case. | ||
| if (n == 0) { | ||
| return NULL; | ||
| } | ||
|
|
||
| // All allocators should contain an integer overflow check. | ||
| // The Standardization Committee recommends that std::length_error | ||
| // be thrown in the case of integer overflow. | ||
| if (n > max_size()) { | ||
| throw std::length_error( | ||
| "aligned_allocator<T>::allocate() - Integer overflow."); | ||
| } | ||
|
|
||
| // std::aligned_alloc will return NULL if you try to allocate less bytes | ||
| // than the alignment So long as the above test against max_size() passes, | ||
| // this multiplication is safe. | ||
| std::size_t alloc = n * sizeof(T); | ||
| if (alloc < Alignment) { | ||
| alloc = Alignment; | ||
| } | ||
|
|
||
| // Allocate memory | ||
| void *const pv = std::aligned_alloc(Alignment, alloc); | ||
|
|
||
| // Allocators should throw std::bad_alloc in the case of memory allocation | ||
| // failure. | ||
| if (pv == NULL) { | ||
| throw std::bad_alloc(); | ||
| } | ||
|
|
||
| return static_cast<T *>(pv); | ||
| } | ||
|
|
||
| void deallocate(T *const p, const std::size_t) const { std::free(p); } | ||
|
|
||
| // The following will be the same for all allocators that ignore hints. | ||
| template <typename U> | ||
| T *allocate(const std::size_t n, const U * /* const hint */) const { | ||
| return allocate(n); | ||
| } | ||
|
|
||
| // Allocators are not required to be assignable, so | ||
| // all allocators should have a private unimplemented | ||
| // assignment operator. Note that this will trigger the | ||
| // off-by-default (enabled under /Wall) warning C4626 | ||
| // "assignment operator could not be generated because a | ||
| // base class assignment operator is inaccessible" within | ||
| // the STL headers, but that warning is useless. | ||
| private: | ||
| aligned_allocator &operator=(const aligned_allocator &); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 2.2.0