Transfer files from RAD repository

This commit is contained in:
Brandon Potter
2024-07-01 09:57:08 -05:00
förälder a30da178c1
incheckning ea8f264a11
382 ändrade filer med 67034 tillägg och 1 borttagningar
+134
Visa fil
@@ -0,0 +1,134 @@
###############################################################################
# Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
#
# 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.
###############################################################################
cmake_minimum_required(VERSION 3.16.3 FATAL_ERROR)
###############################################################################
# GLOBAL COMPILE FLAGS
###############################################################################
if (NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER /opt/rocm/bin/hipcc)
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb")
###############################################################################
# DEFAULT BUILD TYPE
###############################################################################
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE unspecified: generating Release build")
set(
CMAKE_BUILD_TYPE
"Release"
CACHE
STRING
"build type: Release, Debug, RelWithDebInfo, MinSizeRel"
FORCE
)
endif()
###############################################################################
# PROJECT
###############################################################################
project(rocshmem_unit_tests VERSION 1.0.0 LANGUAGES CXX)
###############################################################################
# SOURCES
###############################################################################
add_executable(${PROJECT_NAME} "")
target_include_directories(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/../../library
)
target_sources(
${PROJECT_NAME}
PRIVATE
shmem_gtest.cpp
heap_memory_gtest.cpp
bin_gtest.cpp
binner_gtest.cpp
#bitwise_gtest.cpp # Test is disabled becasue of compilation errors
address_record_gtest.cpp
index_strategy_gtest.cpp
single_heap_gtest.cpp
slab_heap_gtest.cpp
symmetric_heap_gtest.cpp
pow2_bins_gtest.cpp
remote_heap_info_gtest.cpp
mpi_init_singleton_gtest.cpp
spin_ebo_block_mutex_gtest.cpp
abql_block_mutex_gtest.cpp
notifier_gtest.cpp
forward_list_gtest.cpp
free_list_gtest.cpp
)
###############################################################################
# ROCSHMEM DEPENDENCY
###############################################################################
find_package(hip REQUIRED)
target_include_directories(
${PROJECT_NAME}
PRIVATE
rocshmem::rocshmem
)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
rocshmem::rocshmem
hip::host
-fgpu-rdc
)
###############################################################################
# GTEST DEPENDENCY
###############################################################################
include(FetchContent)
FetchContent_Declare(
googletest
PREFIX extern/googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(BUILD_GTEST ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
gtest
gtest_main
)
@@ -0,0 +1,73 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "abql_block_mutex_gtest.hpp"
using namespace rocshmem;
/*****************************************************************************
******************************* Fixture Tests *******************************
*****************************************************************************/
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_1) {
run_all_threads_once(1, 1);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_2) {
run_all_threads_once(1, 2);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_8) {
run_all_threads_once(1, 8);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_64) {
run_all_threads_once(1, 64);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_128) {
run_all_threads_once(1, 128);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_256) {
run_all_threads_once(1, 256);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_1024) {
run_all_threads_once(1, 1024);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_2048) {
run_all_threads_once(1, 2048);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_4096) {
run_all_threads_once(1, 4096);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_8192) {
run_all_threads_once(1, 8192);
}
TEST_F(ABQLBlockMutexTestFixture, run_all_threads_once_1_65536) {
run_all_threads_once(1, 65536);
}
+140
Visa fil
@@ -0,0 +1,140 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_ABQL_BLOCK_MUTEX_GTEST_HPP
#define ROCSHMEM_ABQL_BLOCK_MUTEX_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/hip_allocator.hpp"
#include "../src/sync/abql_block_mutex.hpp"
#include "../src/util.hpp"
namespace rocshmem {
inline __device__
void
increment_counter(ABQLBlockMutex *mutex,
size_t *counter) {
auto ticket {mutex->lock()};
(*counter)++;
__threadfence();
mutex->unlock(ticket);
}
__global__
void
all_threads_once(ABQLBlockMutex *mutex,
size_t *counter) {
increment_counter(mutex, counter);
}
__global__
void
block_leader_once(ABQLBlockMutex *mutex,
size_t *counter) {
if (is_thread_zero_in_block()) {
increment_counter(mutex, counter);
}
}
__global__
void
warp_leader_once(ABQLBlockMutex *mutex,
size_t *counter) {
if (is_thread_zero_in_wave()) {
increment_counter(mutex, counter);
}
}
class ABQLBlockMutexTestFixture : public ::testing::Test {
public:
ABQLBlockMutexTestFixture() {
assert(mutex_ == nullptr);
hip_allocator_.allocate((void**)&mutex_, sizeof(ABQLBlockMutex));
assert(mutex_);
new (mutex_) ABQLBlockMutex();
assert(counter_ == nullptr);
hip_allocator_.allocate((void**)&counter_, sizeof(int));
assert(counter_);
*counter_ = 0;
}
~ABQLBlockMutexTestFixture() {
if (mutex_) {
hip_allocator_.deallocate(mutex_);
}
if (counter_) {
hip_allocator_.deallocate(counter_);
}
}
void
run_all_threads_once(uint32_t x_block_dim,
uint32_t x_grid_dim) {
const dim3 hip_blocksize(x_block_dim, 1, 1);
const dim3 hip_gridsize(x_grid_dim, 1, 1);
hipLaunchKernelGGL(all_threads_once,
hip_gridsize,
hip_blocksize,
0,
nullptr,
mutex_,
counter_);
hipError_t return_code = hipStreamSynchronize(nullptr);
if (return_code != hipSuccess) {
printf("Failed in stream synchronize\n");
assert(return_code == hipSuccess);
}
size_t number_threads {x_block_dim * x_grid_dim};
ASSERT_EQ(*counter_, number_threads);
}
protected:
/**
* @brief An allocator to create objects in device memory.
*/
HIPAllocator hip_allocator_ {};
/**
* @brief A mutex to prevent data races.
*/
ABQLBlockMutex *mutex_ {nullptr};
/**
* @brief A monotonically increasing counter to track accesses.
*/
size_t *counter_ {nullptr};
};
} // namespace rocshmem
#endif // ROCSHMEM_ABQL_BLOCK_MUTEX_GTEST_HPP
+88
Visa fil
@@ -0,0 +1,88 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "address_record_gtest.hpp"
using namespace rocshmem;
TEST_F(AddressRecordTestFixture, split_entry) {
auto [ar1, ar2] = split_.split();
char* a1{reinterpret_cast<char*>(0x200)};
size_t size1{0x40};
ASSERT_EQ(ar1.get_address(), a1);
ASSERT_EQ(ar1.get_size(), size1);
char* a2{reinterpret_cast<char*>(0x240)};
size_t size2{0x40};
ASSERT_EQ(ar2.get_address(), a2);
ASSERT_EQ(ar2.get_size(), size2);
}
#ifdef NDEBUG
TEST_F(AddressRecordTestFixture, DISABLED_split_bad_address)
#else
TEST_F(AddressRecordTestFixture, split_bad_address)
#endif
{
ASSERT_DEATH({ bad_addr_.split(); }, "");
}
#ifdef NDEBUG
TEST_F(AddressRecordTestFixture, DISABLED_split_bad_size)
#else
TEST_F(AddressRecordTestFixture, split_bad_size)
#endif
{
ASSERT_DEATH({ bad_size_.split(); }, "");
}
TEST_F(AddressRecordTestFixture, combine_1_into_combine_2) {
AddressRecord ar{combine_1_.combine(combine_2_)};
ASSERT_EQ(ar.get_address(), combine_1_.get_address());
ASSERT_EQ(ar.get_size(), combine_1_.get_size() << 1);
}
#ifdef NDEBUG
TEST_F(AddressRecordTestFixture, DISABLED_combine_nullptr_record)
#else
TEST_F(AddressRecordTestFixture, combine_nullptr_record)
#endif
{
ASSERT_DEATH({ AddressRecord ar = bad_addr_.combine(combine_2_); }, "");
}
#ifdef NDEBUG
TEST_F(AddressRecordTestFixture, DISABLED_combine_differerent_sizes)
#else
TEST_F(AddressRecordTestFixture, combine_different_sizes)
#endif
{
char* a1{reinterpret_cast<char*>(0x120)};
char* a2{reinterpret_cast<char*>(0x140)};
size_t size1{0x20};
size_t size2{0x40};
AddressRecord ar1{a1, size1};
AddressRecord ar2{a2, size2};
ASSERT_DEATH({ AddressRecord ar = ar1.combine(ar2); }, "");
}
+44
Visa fil
@@ -0,0 +1,44 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_ADDRESS_RECORD_GTEST_HPP
#define ROCSHMEM_ADDRESS_RECORD_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/address_record.hpp"
namespace rocshmem {
class AddressRecordTestFixture : public ::testing::Test
{
protected:
AddressRecord split_ {reinterpret_cast<char*>(0x200), 0x80};
AddressRecord combine_1_ {reinterpret_cast<char*>(0x120), 0x20};
AddressRecord combine_2_ {reinterpret_cast<char*>(0x140), 0x20};
AddressRecord bad_addr_ {nullptr, 0x20};
AddressRecord bad_size_ {reinterpret_cast<char*>(0x800), 0x0};
};
} // namespace rocshmem
#endif // ROCSHMEM_ADDRESS_RECORD_GTEST_HPP
+52
Visa fil
@@ -0,0 +1,52 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "bin_gtest.hpp"
using namespace rocshmem;
TEST_F(BinTestFixture, is_empty_check) { ASSERT_TRUE(bin_.empty()); }
TEST_F(BinTestFixture, is_not_empty_check) {
bin_.put(nullptr);
ASSERT_FALSE(bin_.empty());
}
TEST_F(BinTestFixture, size_check) {
ASSERT_EQ(bin_.size(), 0);
bin_.put(nullptr);
ASSERT_EQ(bin_.size(), 1);
bin_.put(nullptr);
ASSERT_EQ(bin_.size(), 2);
}
TEST_F(BinTestFixture, retrieval_check) {
char* p_xa{reinterpret_cast<char*>(0xa)};
char* p_xb{reinterpret_cast<char*>(0xb)};
bin_.put(p_xa);
bin_.put(p_xb);
auto g_xb = bin_.get();
auto g_xa = bin_.get();
ASSERT_EQ(p_xa, g_xa);
ASSERT_EQ(p_xb, g_xb);
}
+43
Visa fil
@@ -0,0 +1,43 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_BIN_GTEST_HPP
#define ROCSHMEM_BIN_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/bin.hpp"
namespace rocshmem {
class BinTestFixture : public ::testing::Test
{
protected:
/**
* @brief A bin object containing pointers
*/
Bin<char*> bin_ {};
};
} // namespace rocshmem
#endif // ROCSHMEM_BIN_GTEST_HPP
+139
Visa fil
@@ -0,0 +1,139 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "binner_gtest.hpp"
using namespace rocshmem;
TEST(Binner, ffs_0) {
size_t val{0x0};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, UINT_MAX);
}
TEST(Binner, ffs_1) {
size_t val{0x1};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 0);
}
TEST(Binner, ffs_2) {
size_t val{0x2};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 1);
}
TEST(Binner, ffs_4) {
size_t val{0x4};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 2);
}
TEST(Binner, ffs_8) {
size_t val{0x8};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 3);
}
TEST(Binner, ffs_100) {
size_t val{0x100};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 8);
}
TEST(Binner, ffs_8000) {
size_t val{0x8000};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 15);
}
TEST(Binner, ffs_ff80) {
size_t val{0xFF80};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 15);
}
TEST(Binner, ffs_4000_0000) {
size_t val{0x40000000};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 30);
}
TEST(Binner, ffs_0100_0000_0000_0000) {
size_t val{0x0100000000000000};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 56);
}
TEST(Binner, ffs_0200_0000_0000_0000) {
size_t val{0x0200000000000000};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 57);
}
TEST(Binner, ffs_4000_0000_0000_0000) {
size_t val{0x4000000000000000};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 62);
}
TEST(Binner, ffs_8000_0000_0000_0000) {
size_t val{0x8000000000000000};
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 63);
}
TEST(Binner, ffs_max) {
size_t val = -1;
auto bit_pos{find_first_set_one(val)};
ASSERT_EQ(bit_pos, 63);
}
TEST_F(BinnerTestFixture, correct_bin_sizes_one_gig) {
auto bins{binner_.get_bins()};
ASSERT_EQ(bins->size(), 24);
std::array<unsigned, 24> a;
for (unsigned i = 0; i < 24; i++) {
a[i] = i + 7;
}
for (auto e : a) {
bool found = bins->count(std::pow(2, e));
ASSERT_TRUE(found);
}
}
TEST_F(BinnerTestFixture, bin_get_one_gig) {
binner_.assign_heap_to_bins();
auto bins{binner_.get_bins()};
ASSERT_EQ(bins->size(), 24);
size_t gibibyte = std::pow(2, 30);
auto bin{(*bins)[gibibyte]};
ASSERT_EQ(bin.size(), 1);
auto address_record = bin.get();
ASSERT_EQ(address_record.get_size(), gibibyte);
}
+76
Visa fil
@@ -0,0 +1,76 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_BINNER_GTEST_HPP
#define ROCSHMEM_BINNER_GTEST_HPP
#include "gtest/gtest.h"
#include <map>
#include "../src/../src/memory/address_record.hpp"
#include "../src/memory/bin.hpp"
#include "../src/memory/binner.hpp"
#include "../src/memory/heap_memory.hpp"
#include "../src/memory/hip_allocator.hpp"
namespace rocshmem {
class BinnerTestFixture : public ::testing::Test
{
/**
* @brief Helper type for address records
*/
using AR_T = AddressRecord;
/**
* @brief Helper type for size to bin maps
*/
using BINS_T = std::map<size_t, Bin<AR_T>>;
/**
* @brief Helper type for binner
*/
using BINNER_T = Binner<AR_T, BINS_T>;
protected:
/**
* @brief a heap memory object
*/
HeapMemory<HIPAllocator> hm_ {};
/**
* @brief a bins object
*/
BINS_T bins_ {};
/**
* @brief a binner object
*/
BINNER_T binner_ {&bins_,
hm_.get_ptr(),
hm_.get_size()};
};
} // namespace rocshmem
#endif // ROCSHMEM_BINNER_GTEST_HPP
Filskillnaden har hållits tillbaka eftersom den är för stor Load Diff
+364
Visa fil
@@ -0,0 +1,364 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_BITWISE_GTEST_HPP
#define ROCSHMEM_BITWISE_GTEST_HPP
#define HIP_ENABLE_PRINTF
#include "gtest/gtest.h"
#include <hip/hip_runtime.h>
#include "../src/memory/hip_allocator.hpp"
#include "containers/matrix.hpp"
#include "containers/share_strategy.hpp"
#include "containers/strategies.hpp"
namespace rocshmem {
/*****************************************************************************
************************ WarpMatrix Type Helpers ****************************
*****************************************************************************/
typedef Matrix<uint64_t> WarpMatrix;
/*****************************************************************************
***************************** Device Methods ********************************
*****************************************************************************/
class BitwiseDeviceMethods
{
public:
/*************************************************************************
************************* Block Strategy Methods ************************
*************************************************************************/
__device__
void
lowest_active_lane(WarpMatrix *warp_matrix,
size_t lanes_bitfield)
{
Block block {};
if (activate_lane_helper(lanes_bitfield)) {
auto low_lane = block.lowest_active_lane();
size_t warp_index = hipThreadIdx_x / _warp_size;
size_t block_index = hipBlockIdx_x;
auto *elem = warp_matrix->access(warp_index, block_index);
*elem = low_lane;
}
}
__device__
void
is_lowest_active_lane(WarpMatrix *warp_matrix,
size_t lanes_bitfield)
{
Block block {};
if (activate_lane_helper(lanes_bitfield)) {
if (block.is_lowest_active_lane()) {
size_t warp_index = hipThreadIdx_x / _warp_size;
size_t block_index = hipBlockIdx_x;
auto *elem = warp_matrix->access(warp_index, block_index);
*elem = block.lane_id();
}
}
}
__device__
void
active_logical_lane_id_2(WarpMatrix *warp_matrix,
size_t lanes_bitfield)
{
Block block {};
if (activate_lane_helper(lanes_bitfield)) {
if (block.active_logical_lane_id() == 2) {
size_t warp_index = hipThreadIdx_x / _warp_size;
size_t block_index = hipBlockIdx_x;
auto *elem = warp_matrix->access(warp_index, block_index);
*elem = block.lane_id();
}
}
}
__device__
void
lane_id(WarpMatrix *warp_matrix,
size_t lanes_bitfield)
{
Block block {};
if (activate_lane_helper(lanes_bitfield)) {
auto lane_id = block.lane_id();
size_t warp_index = hipThreadIdx_x / _warp_size;
size_t block_index = hipBlockIdx_x;
auto *elem = warp_matrix->access(warp_index, block_index);
*elem = lane_id;
}
}
__device__
void
number_active_lanes(WarpMatrix *warp_matrix,
size_t lanes_bitfield)
{
Block block {};
if (activate_lane_helper(lanes_bitfield)) {
auto number_active_lanes = block.number_active_lanes();
size_t warp_index = hipThreadIdx_x / _warp_size;
size_t block_index = hipBlockIdx_x;
auto *elem = warp_matrix->access(warp_index, block_index);
*elem = number_active_lanes;
}
}
__device__
void
broadcast_up_value_42(WarpMatrix *warp_matrix,
size_t lanes_bitfield)
{
Block block {};
if (activate_lane_helper(lanes_bitfield)) {
uint64_t value = 1;
if (block.is_lowest_active_lane()) {
value = 42;
}
value = block.broadcast_up(value);
size_t warp_index = hipThreadIdx_x / _warp_size;
size_t block_index = hipBlockIdx_x;
auto *elem = warp_matrix->access(warp_index, block_index);
*elem = value;
}
}
__device__
void
fetch_incr_lowest_active_lane(WarpMatrix *warp_matrix,
size_t lanes_bitfield)
{
Block block {};
if (activate_lane_helper(lanes_bitfield)) {
auto orig = block.fetch_incr(_fetch_value);
if (block.is_lowest_active_lane()) {
size_t warp_index = hipThreadIdx_x / _warp_size;
size_t block_index = hipBlockIdx_x;
auto *elem = warp_matrix->access(warp_index, block_index);
*elem = orig;
}
}
}
__device__
void
fetch_incr_active_logical_lane_1(WarpMatrix *warp_matrix,
size_t lanes_bitfield)
{
Block block {};
if (activate_lane_helper(lanes_bitfield)) {
auto orig = block.fetch_incr(_fetch_value);
if (block.active_logical_lane_id() == 1) {
size_t warp_index = hipThreadIdx_x / _warp_size;
size_t block_index = hipBlockIdx_x;
auto *elem = warp_matrix->access(warp_index, block_index);
*elem = orig;
}
}
}
/*************************************************************************
************************* Helper Methods ********************************
*************************************************************************/
__device__
bool
activate_lane_helper(uint64_t lanes_bitfield)
{
/*
* In the following example, assume the following values:
* hipThreadIdx_x := 66
* _warp_size := 64.
*
* index (tens): 0 0 0 0 0 0 0 ... 6 6 . .
* (ones): 0 1 2 3 4 5 6 ... 2 3 . .
* lanes_bitfield: [1 0 1 0 1 0 1 ... 1 0 . .]
*
* Example:
* warp_bit_id := hipThreadIdx_x % _warp_size;
* warp_bit_id := 66 % 64
* warp_bit_id := 2
*/
uint64_t warp_bit_id = hipThreadIdx_x % _warp_size;
/*
* Example (continued):
* warp_bitmask := 1 << 2
* index (tens): 0 0 0 0 0 0 0 ... 6 6 . .
* (ones): 0 1 2 3 4 5 6 ... 2 3 . .
* warp_bitmask: [0 0 1 0 0 0 0 ... 0 0 . .]
*/
uint64_t my_warp_bitmask_id = 1UL << warp_bit_id;
/*
* Example (continued):
* index (tens): 0 0 0 0 0 0 0 ... 6 6 . .
* (ones): 0 1 2 3 4 5 6 ... 2 3 . .
* lanes_bitfield: [1 0 1 0 1 0 1 ... 1 0 . .]
* warp_bitmask: [0 0 1 0 0 0 0 ... 0 0 . .]
*/
bool is_an_active_lane = lanes_bitfield & my_warp_bitmask_id;
return is_an_active_lane;
}
__device__
uint64_t
warp_size() const
{
return _warp_size;
}
long long unsigned *_fetch_value = nullptr;
private:
/*************************************************************************
********************** Implementation Variables *************************
*************************************************************************/
static constexpr uint64_t _warp_size = __AMDGCN_WAVEFRONT_SIZE;
};
/*****************************************************************************
***************************** Test Fixture **********************************
*****************************************************************************/
class BitwiseTestFixture : public ::testing::Test
{
public:
BitwiseTestFixture() = default;
~BitwiseTestFixture()
{
if (_device_methods) {
if (_device_methods->_fetch_value) {
_hip_allocator.deallocate(_device_methods->_fetch_value);
}
_hip_allocator.deallocate(_device_methods);
}
if (_warp_matrix) {
_hip_allocator.deallocate(_warp_matrix);
}
}
/*************************************************************************
**************************** Setup Methods ******************************
*************************************************************************/
void
setup_fixture(dim3 block_dim, dim3 grid_dim)
{
_hip_block_dim = block_dim;
_hip_grid_dim = grid_dim;
assert(_device_methods == nullptr);
_hip_allocator.allocate(reinterpret_cast<void**>(&_device_methods),
sizeof(BitwiseDeviceMethods));
assert(_device_methods);
_hip_allocator.allocate(reinterpret_cast<void**>(&_device_methods->_fetch_value),
sizeof(long long unsigned));
assert(_device_methods->_fetch_value);
*_device_methods->_fetch_value = 0;
assert(_warp_matrix == nullptr);
_hip_allocator.allocate(reinterpret_cast<void**>(&_warp_matrix),
sizeof(WarpMatrix));
size_t warps_per_block = ceil(float(_hip_block_dim.x) / _warp_size);
const ObjectStrategy *default_object_strategy =
DefaultObjectStrategy::instance()->get();
assert(_warp_matrix);
new (_warp_matrix) WarpMatrix(warps_per_block,
_hip_grid_dim.x,
_hip_allocator,
*default_object_strategy);
}
void
zero_warp_matrix()
{
for (size_t row = 0; row < _warp_matrix->rows(); row++) {
for (size_t col = 0; col < _warp_matrix->columns(); col++) {
auto *entry = _warp_matrix->access(row, col);
*entry = 0;
}
}
}
void
verify_zeroed_warp_matrix()
{
for (size_t row = 0; row < _warp_matrix->rows(); row++) {
for (size_t col = 0; col < _warp_matrix->columns(); col++) {
auto *entry = _warp_matrix->access(row, col);
ASSERT_EQ(*entry, 0);
}
}
}
/*************************************************************************
*********************** Kernel Launch Methods ***************************
*************************************************************************/
void
host_run_device_kernel(void(*fn)(BitwiseDeviceMethods*,
WarpMatrix*,
size_t),
size_t activate_lanes_bitfield)
{
hipLaunchKernelGGL(fn,
_hip_grid_dim,
_hip_block_dim,
0,
nullptr,
_device_methods,
_warp_matrix,
activate_lanes_bitfield);
hipError_t return_code = hipStreamSynchronize(nullptr);
if (return_code != hipSuccess) {
printf("Failed in stream synchronize\n");
assert(return_code == hipSuccess);
}
}
protected:
/*************************************************************************
********************** Implementation Variables *************************
*************************************************************************/
dim3 _hip_block_dim {};
dim3 _hip_grid_dim {};
HIPAllocator _hip_allocator {};
static constexpr uint64_t _warp_size = __AMDGCN_WAVEFRONT_SIZE;
WarpMatrix *_warp_matrix = nullptr;
BitwiseDeviceMethods *_device_methods = nullptr;
};
} // namespace rocshmem
#endif // ROCSHMEM_BITWISE_GTEST_HPP
+51
Visa fil
@@ -0,0 +1,51 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "forward_list_gtest.hpp"
#include <iostream>
#include <string>
using namespace rocshmem;
/*****************************************************************************
******************************* Fixture Tests *******************************
*****************************************************************************/
TEST_F(ForwardListTestFixture, default_constructor) {
default_constructor_test();
}
TEST(ForwardListTest, constructor_tests) {
ForwardList<std::string> list_1{"rocshmem", "forward_list"};
std::string str_1 = "rocshmem forward_list";
ASSERT_EQ(to_string(list_1), str_1);
// ForwardList<std::string> list_2(list_1.begin(), list_1.end());
// std::cout << "list_2: " << list_2 << '\n';
// ForwardList<std::string> list_3(list_1);
// std::cout << "list_3: " << list_3 << '\n';
// ForwardList<std::string> list_4(5, "rocm");
// std::cout << "list_4: " << list_4 << '\n';
}
+50
Visa fil
@@ -0,0 +1,50 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_FORWARD_LIST_GTEST_HPP
#define ROCSHMEM_FORWARD_LIST_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/containers/forward_list_impl.hpp"
#include "../src/memory/hip_allocator.hpp"
namespace rocshmem {
class ForwardListTestFixture : public ::testing::Test {
public:
ForwardListTestFixture() {
}
void
default_constructor_test() {
ASSERT_EQ(list_.head_, nullptr);
ASSERT_EQ(to_string(list_), std::string{});
}
private:
ForwardList<std::string> list_ {};
};
} // namespace rocshmem
#endif // ROCSHMEM_FORWARD_LIST_GTEST_HPP
+233
Visa fil
@@ -0,0 +1,233 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "free_list_gtest.hpp"
#include <thrust/sort.h>
#include "../src/util.hpp"
using namespace rocshmem;
/*****************************************************************************
******************************* Fixture Tests *******************************
*****************************************************************************/
namespace rocshmem {
template <typename List, typename Value>
__global__ void pop_all(List* list, Value* values, const std::size_t count) {
const auto stride = blockDim.x * gridDim.x;
const auto thread_index = blockIdx.x * blockDim.x + threadIdx.x;
// One push per block. block size is always WF_SIZE
for (std::size_t i = thread_index; i < count * WF_SIZE; i += stride) {
if (is_thread_zero_in_wave()) {
auto last = list->pop_front();
if (values != nullptr) {
values[i / WF_SIZE] = last.value;
}
}
}
}
template <typename List, typename Value>
__global__ void push_all(List* list, const Value* values,
const std::size_t count) {
const auto stride = blockDim.x * gridDim.x;
const auto thread_index = blockIdx.x * blockDim.x + threadIdx.x;
// One push per block. block size is always WF_SIZE
for (std::size_t i = thread_index; i < count * WF_SIZE; i += stride) {
if (is_thread_zero_in_wave()) {
list->push_back(values[i / WF_SIZE]);
}
}
}
template <typename List>
__global__ void pop_empty(List* list, bool* empty) {
auto pop_result = list->pop_front();
*empty = !pop_result.success;
}
} // namespace rocshmem
TYPED_TEST(FreeListTestFixture, pop_empty_device) {
using Allocator = typename TestFixture::Allocator;
using T = typename TestFixture::T;
auto& h_input = this->h_input;
auto& d_input = this->d_input;
auto& free_list = this->free_list;
FreeListProxy<Allocator, T> empty_list_proxy{};
FreeList<T, Allocator>* empty_free_list{empty_list_proxy.get()};
thrust::device_vector<bool> is_empty(1);
rocshmem::pop_empty<<<1, 1>>>(empty_free_list, is_empty.data().get());
CHECK_HIP(hipDeviceSynchronize());
EXPECT_TRUE(is_empty[0]);
}
TYPED_TEST(FreeListTestFixture, push_host_pop_device) {
using Allocator = typename TestFixture::Allocator;
using T = typename TestFixture::T;
auto& h_input = this->h_input;
auto& d_input = this->d_input;
auto& free_list = this->free_list;
thrust::device_vector<T> results(h_input.size());
const auto block_size = WF_SIZE;
rocshmem::pop_all<<<1, block_size>>>(free_list, results.data().get(),
results.size());
CHECK_HIP(hipDeviceSynchronize());
for (std::size_t i = 0; i < results.size(); i++) {
EXPECT_EQ(results[i], h_input[i]);
}
thrust::device_vector<bool> is_empty(1);
rocshmem::pop_empty<<<1, 1>>>(free_list, is_empty.data().get());
CHECK_HIP(hipDeviceSynchronize());
EXPECT_TRUE(is_empty[0]);
}
TYPED_TEST(FreeListTestFixture, push_host_concurrent_pop_device) {
using Allocator = typename TestFixture::Allocator;
using T = typename TestFixture::T;
auto& h_input = this->h_input;
auto& d_input = this->d_input;
auto& free_list = this->free_list;
thrust::device_vector<T> results(h_input.size());
const auto num_blocks = h_input.size();
const auto block_size = WF_SIZE;
rocshmem::pop_all<<<num_blocks, block_size>>>(free_list, results.data().get(),
results.size());
CHECK_HIP(hipDeviceSynchronize());
// sort to guarantee that the ordering is correct
thrust::sort(results.begin(), results.end());
thrust::sort(h_input.begin(), h_input.end());
for (std::size_t i = 0; i < results.size(); i++) {
EXPECT_EQ(results[i], h_input[i]);
}
thrust::device_vector<bool> is_empty(1);
rocshmem::pop_empty<<<1, 1>>>(free_list, is_empty.data().get());
CHECK_HIP(hipDeviceSynchronize());
EXPECT_TRUE(is_empty[0]);
}
TYPED_TEST(FreeListTestFixture, push_host_pop_push_device) {
using Allocator = typename TestFixture::Allocator;
using T = typename TestFixture::T;
using FreeListType = FreeList<T, Allocator>;
auto& h_input = this->h_input;
auto& d_input = this->d_input;
auto& free_list = this->free_list;
const auto block_size = WF_SIZE;
rocshmem::pop_all<FreeListType, T><<<1, block_size>>>(free_list, nullptr, 0);
CHECK_HIP(hipDeviceSynchronize());
rocshmem::push_all<<<1, 1>>>(free_list, d_input.data().get(), d_input.size());
CHECK_HIP(hipDeviceSynchronize());
thrust::device_vector<T> results(d_input.size());
rocshmem::pop_all<<<1, block_size>>>(free_list, results.data().get(),
results.size());
for (std::size_t i = 0; i < results.size(); i++) {
EXPECT_EQ(results[i], h_input[i]);
}
}
TYPED_TEST(FreeListTestFixture, push_host_pop_concurrent_push_device) {
using Allocator = typename TestFixture::Allocator;
using T = typename TestFixture::T;
using FreeListType = FreeList<T, Allocator>;
auto& h_input = this->h_input;
auto& d_input = this->d_input;
auto& free_list = this->free_list;
const auto block_size = WF_SIZE;
rocshmem::pop_all<FreeListType, T><<<1, block_size>>>(free_list, nullptr, 0);
CHECK_HIP(hipDeviceSynchronize());
// Concurrently push all values
const auto num_blocks = h_input.size();
rocshmem::push_all<<<num_blocks, block_size>>>(
free_list, d_input.data().get(), d_input.size());
CHECK_HIP(hipDeviceSynchronize());
thrust::device_vector<T> results(d_input.size());
rocshmem::pop_all<<<1, block_size>>>(free_list, results.data().get(),
results.size());
// Sort to guarantee that the ordering is correct
thrust::sort(results.begin(), results.end());
thrust::sort(h_input.begin(), h_input.end());
for (std::size_t i = 0; i < results.size(); i++) {
EXPECT_EQ(results[i], h_input[i]);
}
}
TYPED_TEST(FreeListTestFixture, push_host_concurrent_pop_push_device) {
using Allocator = typename TestFixture::Allocator;
using T = typename TestFixture::T;
using FreeListType = FreeList<T, Allocator>;
auto& h_input = this->h_input;
auto& d_input = this->d_input;
auto& free_list = this->free_list;
const auto block_size = WF_SIZE;
rocshmem::pop_all<FreeListType, T><<<1, block_size>>>(free_list, nullptr, 0);
CHECK_HIP(hipDeviceSynchronize());
// Concurrently push all values
const auto num_blocks = h_input.size();
rocshmem::push_all<<<num_blocks, block_size>>>(
free_list, d_input.data().get(), d_input.size());
CHECK_HIP(hipDeviceSynchronize());
// Concurrently pop all values
thrust::device_vector<T> results(d_input.size());
rocshmem::pop_all<<<num_blocks, block_size>>>(free_list, results.data().get(),
results.size());
// Sort to guarantee that the ordering is correct
thrust::sort(results.begin(), results.end());
thrust::sort(h_input.begin(), h_input.end());
for (std::size_t i = 0; i < results.size(); i++) {
EXPECT_EQ(results[i], h_input[i]);
}
}
+66
Visa fil
@@ -0,0 +1,66 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_FREE_LIST_GTEST_HPP
#define ROCSHMEM_FREE_LIST_GTEST_HPP
#include <thrust/device_vector.h>
#include <numeric>
#include <vector>
#include "../src/containers/free_list_impl.hpp"
#include "gtest/gtest.h"
#include "../src/memory/hip_allocator.hpp"
namespace rocshmem {
template <typename ValueType>
class FreeListTestFixture : public ::testing::Test {
public:
FreeListTestFixture() : h_input(num_elements) {
std::iota(h_input.begin(), h_input.end(), T{1});
d_input = h_input;
free_list = list_proxy.get();
}
protected:
void SetUp() override {
free_list->push_back_range(h_input.begin(), h_input.end());
}
using T = ValueType;
using Allocator = HIPAllocator;
const std::size_t num_elements{32};
std::vector<T> h_input{};
thrust::device_vector<T> d_input{};
FreeListProxy<Allocator, T> list_proxy{};
FreeList<T, Allocator>* free_list{};
};
using TestTypes = ::testing::Types<std::uint32_t, std::uint64_t>;
TYPED_TEST_SUITE(FreeListTestFixture, TestTypes);
} // namespace rocshmem
#endif // ROCSHMEM_FREE_LIST_GTEST_HPP
+39
Visa fil
@@ -0,0 +1,39 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "heap_memory_gtest.hpp"
using namespace rocshmem;
TEST(HeapMemoryTest, size_constructor) {
HeapMemory<HIPAllocator> heap_mem{2048};
ASSERT_EQ(heap_mem.get_size(), 2048);
ASSERT_NE(heap_mem.get_ptr(), nullptr);
}
TEST_F(HeapMemoryTestFixture, size_check) {
ASSERT_EQ(heap_mem_.get_size(), 1 << 30);
}
TEST_F(HeapMemoryTestFixture, ptr_check) {
ASSERT_NE(heap_mem_.get_ptr(), nullptr);
}
+46
Visa fil
@@ -0,0 +1,46 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_HEAP_MEMORY_GTEST_HPP
#define ROCSHMEM_HEAP_MEMORY_GTEST_HPP
#include "gtest/gtest.h"
#include <hip/hip_runtime_api.h>
#include "../src/memory/hip_allocator.hpp"
#include "../src/memory/heap_memory.hpp"
namespace rocshmem {
class HeapMemoryTestFixture : public ::testing::Test
{
protected:
/**
* @brief a heap memory object
*/
HeapMemory<HIPAllocator> heap_mem_ {};
};
} // namespace rocshmem
#endif // ROCSHMEM_HEAP_MEMORY_GTEST_HPP
+155
Visa fil
@@ -0,0 +1,155 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "index_strategy_gtest.hpp"
#define HIP_ENABLE_PRINTF
using namespace rocshmem;
TEST_F(IndexStrategyTestFixture,
run_TCBA_memory_set_test_grid_1_1_1_block_1_1_1) {
using IndexStrategy = Thread_Contiguous_Block_Agnostic;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {1, 1, 1});
}
//=============================================================================
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_1_1_1_block_64_1_1) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {64, 1, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_1_1_1_block_64_2_1) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {64, 2, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_1_1_1_block_64_4_1) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {64, 4, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_1_1_1_block_64_16_1) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {64, 16, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_1_1_1_block_16_16_4) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {16, 16, 4});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_4_1_1_block_16_16_4) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({4, 1, 1}, {16, 16, 4});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_4_4_4_block_16_16_4) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({4, 4, 4}, {16, 16, 4});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_1024_8_8_block_1024_1_1) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({1024, 8, 8}, {1024, 1, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_1024_8_8_block_1_1024_1) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({1024, 8, 8}, {1, 1024, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBD_memory_set_test_grid_1024_8_8_block_1_1_1024) {
using IndexStrategy = Thread_Discontiguous_Block_Discontiguous;
run_memory_set_test<IndexStrategy>({1024, 8, 8}, {1, 1, 1024});
}
//=============================================================================
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_1_1_1_block_64_1_1) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {64, 1, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_1_1_1_block_64_2_1) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {64, 2, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_1_1_1_block_64_4_1) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {64, 4, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_1_1_1_block_64_16_1) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {64, 16, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_1_1_1_block_16_16_4) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({1, 1, 1}, {16, 16, 4});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_4_1_1_block_16_16_4) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({4, 1, 1}, {16, 16, 4});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_4_4_4_block_16_16_4) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({4, 4, 4}, {16, 16, 4});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_1024_8_8_block_1024_1_1) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({1024, 8, 8}, {1024, 1, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_1024_8_8_block_1_1024_1) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({1024, 8, 8}, {1, 1024, 1});
}
TEST_F(IndexStrategyTestFixture,
run_TDBC_memory_set_test_grid_1024_8_8_block_1_1_1024) {
using IndexStrategy = Thread_Discontiguous_Block_Contiguous;
run_memory_set_test<IndexStrategy>({1024, 8, 8}, {1, 1, 1024});
}
+105
Visa fil
@@ -0,0 +1,105 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_INDEX_STRATEGY_GTEST_HPP
#define ROCSHMEM_INDEX_STRATEGY_GTEST_HPP
#include "gtest/gtest.h"
#include <hip/hip_runtime_api.h>
#include "../src/containers/index_strategy.hpp"
#include "../src/memory/hip_allocator.hpp"
namespace rocshmem {
template <typename INDEX_STRAT>
__global__
void
memory_set(int *raw_mem, size_t num_elems)
{
assert(raw_mem);
INDEX_STRAT idx_strat(num_elems);
for (size_t i = idx_strat.start();
i < idx_strat.end();
i = idx_strat.next(i)) {
raw_mem[i]++;
}
}
class IndexStrategyTestFixture : public ::testing::Test
{
public:
IndexStrategyTestFixture()
{
assert(_raw_mem == nullptr);
size_t raw_mem_size_bytes = sizeof(int) * _mem_elements;
_hip_allocator.allocate(reinterpret_cast<void**>(&_raw_mem),
raw_mem_size_bytes);
assert(_raw_mem);
for (size_t i = 0; i < _mem_elements; i++) {
_raw_mem[i] = 0;
}
}
~IndexStrategyTestFixture()
{
if (_raw_mem) {
_hip_allocator.deallocate(_raw_mem);
}
}
template <typename INDEX_STRAT>
void
run_memory_set_test(const dim3 grid_dim, const dim3 block_dim)
{
hipLaunchKernelGGL(memory_set<INDEX_STRAT>,
grid_dim,
block_dim,
0,
nullptr,
_raw_mem,
_mem_elements);
hipError_t return_code = hipStreamSynchronize(nullptr);
if (return_code != hipSuccess) {
printf("Failed in stream synchronize\n");
assert(return_code == hipSuccess);
}
for(size_t i = 0; i < _mem_elements; i++) {
EXPECT_EQ(_raw_mem[i], 1);
}
}
protected:
int *_raw_mem = nullptr;
HIPAllocator _hip_allocator {};
static constexpr size_t _mem_elements = 262144;
};
} // namespace rocshmem
#endif // ROCSHMEM_INDEX_STRATEGY_GTEST_HPP
@@ -0,0 +1,35 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "mpi_init_singleton_gtest.hpp"
using namespace rocshmem;
TEST_F(MPIInitSingletonTestFixture, library_initialize_destroy) {}
TEST_F(MPIInitSingletonTestFixture, rank) {
ASSERT_NO_FATAL_FAILURE(s_ptr_->get_rank());
}
TEST_F(MPIInitSingletonTestFixture, nprocs) {
ASSERT_EQ(s_ptr_->get_nprocs(), 4);
}
@@ -0,0 +1,48 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_MPI_INIT_SINGLETON_GTEST_HPP
#define ROCSHMEM_MPI_INIT_SINGLETON_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/mpi_init_singleton.hpp"
namespace rocshmem {
class MPIInitSingletonTestFixture : public ::testing::Test
{
public:
MPIInitSingletonTestFixture() {
s_ptr_ = s_ptr_->GetInstance();
}
protected:
/**
* @brief A singleton object used to initialize MPI
*/
MPIInitSingleton* s_ptr_ {nullptr};
};
} // namespace rocshmem
#endif // ROCSHMEM_MPI_INIT_SINGLETON_GTEST_HPP
+57
Visa fil
@@ -0,0 +1,57 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "notifier_gtest.hpp"
using namespace rocshmem;
/*****************************************************************************
******************************* Fixture Tests *******************************
*****************************************************************************/
TEST_F(NotifierTestFixture, run_all_threads_once_1_1) {
run_all_threads_once(1, 1);
}
TEST_F(NotifierTestFixture, run_all_threads_once_2_1) {
run_all_threads_once(2, 1);
}
TEST_F(NotifierTestFixture, run_all_threads_once_64_1) {
run_all_threads_once(64, 1);
}
TEST_F(NotifierTestFixture, run_all_threads_once_128_1) {
run_all_threads_once(128, 1);
}
TEST_F(NotifierTestFixture, run_all_threads_once_256_1) {
run_all_threads_once(256, 1);
}
TEST_F(NotifierTestFixture, run_all_threads_once_512_1) {
run_all_threads_once(512, 1);
}
TEST_F(NotifierTestFixture, run_all_threads_once_1024_1) {
run_all_threads_once(1024, 1);
}
+148
Visa fil
@@ -0,0 +1,148 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_NOTIFIER_GTEST_HPP
#define ROCSHMEM_NOTIFIER_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/hip_allocator.hpp"
#include "../src/memory/notifier.hpp"
#include "../src/util.hpp"
namespace rocshmem {
/**
* @brief The bit pattern written to memory by each thread.
*/
static const uint8_t THREAD_VALUE {0xF9};
/**
* @brief The bit pattern written to memory by each thread.
*/
static const uint64_t NOTIFIER_OFFSET {0x100B00};
inline __device__
void
write_to_memory(uint8_t* raw_memory) {
auto thread_idx {get_flat_block_id()};
raw_memory[thread_idx] = THREAD_VALUE;
__threadfence();
}
__global__
void
all_threads_once(uint8_t* raw_memory,
Notifier* notifier) {
notifier->write(NOTIFIER_OFFSET);
uint64_t offset_u64 {notifier->read()};
notifier->done();
uint64_t raw_memory_u64 {reinterpret_cast<uint64_t>(raw_memory)};
uint64_t address_u64 {raw_memory_u64 + offset_u64};
uint8_t* address {reinterpret_cast<uint8_t*>(address_u64)};
write_to_memory(address);
__syncthreads();
}
class NotifierTestFixture : public ::testing::Test {
using NotifierProxyT = NotifierProxy<HIPAllocator>;
public:
NotifierTestFixture() {
assert(raw_memory_ == nullptr);
hip_allocator_.allocate((void**)&raw_memory_, GIBIBYTE_);
assert(raw_memory_);
}
~NotifierTestFixture() {
if (raw_memory_) {
hip_allocator_.deallocate(raw_memory_);
}
}
void
run_all_threads_once(uint32_t x_block_dim,
uint32_t x_grid_dim) {
const dim3 hip_blocksize(x_block_dim, 1, 1);
const dim3 hip_gridsize(x_grid_dim, 1, 1);
hipLaunchKernelGGL(all_threads_once,
hip_gridsize,
hip_blocksize,
0,
nullptr,
raw_memory_,
notifier_.get());
hipError_t return_code = hipStreamSynchronize(nullptr);
if (return_code != hipSuccess) {
printf("Failed in stream synchronize\n");
assert(return_code == hipSuccess);
}
size_t number_threads {x_block_dim * x_grid_dim};
uint8_t* offset_addr {compute_offset_addr()};
for (size_t i {0}; i < number_threads; i++) {
ASSERT_EQ(offset_addr[i], THREAD_VALUE);
}
}
protected:
/**
* @brief Helper function to reconstruct device calculation.
*/
uint8_t*
compute_offset_addr() {
uint64_t raw_memory_u64 {reinterpret_cast<uint64_t>(raw_memory_)};
uint64_t address_u64 {raw_memory_u64 + NOTIFIER_OFFSET};
uint8_t* address {reinterpret_cast<uint8_t*>(address_u64)};
return address;
}
/**
* @brief An allocator to create objects in device memory.
*/
HIPAllocator hip_allocator_ {};
/**
* @brief The size of the raw memory block below.
*/
static const size_t GIBIBYTE_ {1 << 30};
/**
* @brief A block of memory used to hold individual writes from threads.
*/
uint8_t *raw_memory_ {nullptr};
/**
* @brief Used to broadcast base offset for writing.
*/
NotifierProxyT notifier_ {};
};
} // namespace rocshmem
#endif // ROCSHMEM_NOTIFIER_GTEST_HPP
+157
Visa fil
@@ -0,0 +1,157 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "pow2_bins_gtest.hpp"
using namespace rocshmem;
TEST_F(Pow2BinsTestFixture, alloc_0_bytes) {
char* c_ptr{nullptr};
size_t size{0};
strat_.alloc(&c_ptr, size);
ASSERT_EQ(c_ptr, nullptr);
}
TEST_F(Pow2BinsTestFixture, alloc_1_byte) {
char* c_ptr{nullptr};
size_t size{1};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
size_t min_size{256};
auto bins{strat_.get_bins()};
auto bin{(*bins)[min_size]};
ASSERT_EQ(bin.size(), 1);
}
TEST_F(Pow2BinsTestFixture, alloc_128_bytes) {
char* c_ptr{nullptr};
size_t size{128};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
size_t min_size{256};
auto bins{strat_.get_bins()};
auto bin{(*bins)[min_size]};
ASSERT_EQ(bin.size(), 1);
}
TEST_F(Pow2BinsTestFixture, alloc_256_bytes) {
char* c_ptr{nullptr};
size_t size{256};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
auto bins{strat_.get_bins()};
auto bin{(*bins)[size]};
ASSERT_EQ(bin.size(), 1);
}
TEST_F(Pow2BinsTestFixture, alloc_512_bytes) {
char* c_ptr{nullptr};
size_t size{512};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
auto bins{strat_.get_bins()};
auto bin{(*bins)[size]};
ASSERT_EQ(bin.size(), 1);
}
TEST_F(Pow2BinsTestFixture, alloc_513_bytes) {
char* c_ptr{nullptr};
size_t size{513};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
size_t min_size{1024};
auto bins{strat_.get_bins()};
auto bin{(*bins)[min_size]};
ASSERT_EQ(bin.size(), 1);
}
TEST_F(Pow2BinsTestFixture, alloc_4KB) {
char* c_ptr{nullptr};
size_t size{4096};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
auto bins{strat_.get_bins()};
auto bin{(*bins)[size]};
ASSERT_EQ(bin.size(), 1);
}
TEST_F(Pow2BinsTestFixture, alloc_128KB) {
char* c_ptr{nullptr};
size_t size{131072};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
auto bins{strat_.get_bins()};
auto bin{(*bins)[size]};
ASSERT_EQ(bin.size(), 1);
}
TEST_F(Pow2BinsTestFixture, alloc_1GB) {
char* c_ptr{nullptr};
size_t size{1 << 30};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
auto bins{strat_.get_bins()};
auto bin{(*bins)[size]};
ASSERT_EQ(bin.size(), 0);
}
TEST_F(Pow2BinsTestFixture, alloc_256_bytes_X2_free_256_bytes_X2) {
char* c_ptr_1{nullptr};
char* c_ptr_2{nullptr};
size_t size{256};
strat_.alloc(&c_ptr_1, size);
ASSERT_NE(c_ptr_1, nullptr);
strat_.alloc(&c_ptr_2, size);
ASSERT_NE(c_ptr_2, nullptr);
auto bins{strat_.get_bins()};
auto& bin{(*bins)[size]};
ASSERT_EQ(bin.size(), 0);
strat_.free(c_ptr_1);
strat_.free(c_ptr_2);
ASSERT_EQ(bin.size(), 2);
}
TEST_F(Pow2BinsTestFixture, alloc_1GB_free_1GB) {
char* c_ptr{nullptr};
size_t size{1 << 30};
strat_.alloc(&c_ptr, size);
ASSERT_NE(c_ptr, nullptr);
auto bins{strat_.get_bins()};
auto& bin{(*bins)[size]};
ASSERT_EQ(bin.size(), 0);
strat_.free(c_ptr);
ASSERT_EQ(bin.size(), 1);
}
+66
Visa fil
@@ -0,0 +1,66 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_POW2_BINS_GTEST_HPP
#define ROCSHMEM_POW2_BINS_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/address_record.hpp"
#include "../src/memory/heap_memory.hpp"
#include "../src/memory/hip_allocator.hpp"
#include "../src/memory/pow2_bins.hpp"
namespace rocshmem {
class Pow2BinsTestFixture : public ::testing::Test
{
/**
* @brief Helper type for heap memory
*/
using HEAP_T = HeapMemory<HIPAllocator>;
/**
* @brief Helper type for address records
*/
using AR_T = AddressRecord;
/**
* @brief Helper type for allocation strategy
*/
using STRAT_T = Pow2Bins<AR_T, HEAP_T>;
protected:
/**
* @brief Heap memory object
*/
HEAP_T heap_mem_ {};
/**
* @brief Allocation strategy object
*/
STRAT_T strat_ {&heap_mem_};
};
} // namespace rocshmem
#endif // ROCSHMEM_POW2_BINS_GTEST_HPP
@@ -0,0 +1,37 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "remote_heap_info_gtest.hpp"
using namespace rocshmem;
TEST_F(RemoteHeapInfoTestFixture, MPI_num_pes) { ASSERT_EQ(mpi_.num_pes(), 4); }
TEST_F(RemoteHeapInfoTestFixture, MPI_barrier) {
ASSERT_NO_FATAL_FAILURE(mpi_.barrier());
}
TEST_F(RemoteHeapInfoTestFixture, MPI_bases) {
for (auto base : mpi_.get_heap_bases()) {
ASSERT_NE(base, nullptr);
}
}
@@ -0,0 +1,61 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_REMOTE_HEAP_INFO_GTEST_HPP
#define ROCSHMEM_REMOTE_HEAP_INFO_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/heap_memory.hpp"
#include "../src/memory/hip_allocator.hpp"
#include "../src/memory/remote_heap_info.hpp"
namespace rocshmem {
class RemoteHeapInfoTestFixture : public ::testing::Test
{
/**
* @brief Helper type for heap memory
*/
using HEAP_T = HeapMemory<HIPAllocator>;
/**
* @brief Helper type for RemoteHeapInfo with MPI
*/
using MPI_T = RemoteHeapInfo<CommunicatorMPI>;
protected:
/**
* @brief Heap memory object
*/
HEAP_T heap_mem_ {};
/**
* @brief Remote heap info with MPI Communicator
*/
MPI_T mpi_ {heap_mem_.get_ptr(),
heap_mem_.get_size()};
};
} // namespace rocshmem
#endif // ROCSHMEM_REMOTE_HEAP_INFO_GTEST_HPP
+28
Visa fil
@@ -0,0 +1,28 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "gtest/gtest.h"
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
+142
Visa fil
@@ -0,0 +1,142 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "single_heap_gtest.hpp"
using namespace rocshmem;
TEST_F(SingleHeapTestFixture, unallocated_size_check) {
ASSERT_EQ(single_heap_.get_size(), 1 << 30);
}
TEST_F(SingleHeapTestFixture, unallocated_avail_check) {
ASSERT_EQ(single_heap_.get_avail(), 1 << 30);
}
TEST_F(SingleHeapTestFixture, unallocated_used_check) {
ASSERT_EQ(single_heap_.get_used(), 0);
}
TEST_F(SingleHeapTestFixture, free_null) {
void* ptr{nullptr};
single_heap_.free(ptr);
}
TEST_F(SingleHeapTestFixture, alloc_0) {
size_t request_size{0};
void* ptr{nullptr};
single_heap_.malloc(&ptr, request_size);
ASSERT_EQ(ptr, nullptr);
size_t expected_used{request_size};
ASSERT_EQ(single_heap_.get_used(), expected_used);
size_t expected_avail{single_heap_.get_size() - expected_used};
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
single_heap_.free(ptr);
expected_used = 0;
ASSERT_EQ(single_heap_.get_used(), expected_used);
expected_avail = single_heap_.get_size();
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
}
TEST_F(SingleHeapTestFixture, alloc_1) {
size_t request_size{1};
void* ptr{nullptr};
single_heap_.malloc(&ptr, request_size);
ASSERT_NE(ptr, nullptr);
size_t expected_used{128};
ASSERT_EQ(single_heap_.get_used(), expected_used);
size_t expected_avail{single_heap_.get_size() - expected_used};
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
single_heap_.free(ptr);
expected_used = 0;
ASSERT_EQ(single_heap_.get_used(), expected_used);
expected_avail = single_heap_.get_size();
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
}
TEST_F(SingleHeapTestFixture, alloc_256) {
size_t request_size{256};
void* ptr{nullptr};
single_heap_.malloc(&ptr, request_size);
ASSERT_NE(ptr, nullptr);
size_t expected_used{request_size};
ASSERT_EQ(single_heap_.get_used(), expected_used);
size_t expected_avail{single_heap_.get_size() - expected_used};
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
single_heap_.free(ptr);
expected_used = 0;
ASSERT_EQ(single_heap_.get_used(), expected_used);
expected_avail = single_heap_.get_size();
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
}
TEST_F(SingleHeapTestFixture, alloc_1024) {
size_t request_size{1024};
void* ptr{nullptr};
single_heap_.malloc(&ptr, request_size);
ASSERT_NE(ptr, nullptr);
size_t expected_used{request_size};
ASSERT_EQ(single_heap_.get_used(), expected_used);
size_t expected_avail{single_heap_.get_size() - expected_used};
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
single_heap_.free(ptr);
expected_used = 0;
ASSERT_EQ(single_heap_.get_used(), expected_used);
expected_avail = single_heap_.get_size();
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
}
TEST_F(SingleHeapTestFixture, alloc_4097) {
size_t request_size{4097};
void* ptr{nullptr};
single_heap_.malloc(&ptr, request_size);
ASSERT_NE(ptr, nullptr);
size_t expected_used{8192};
ASSERT_EQ(single_heap_.get_used(), expected_used);
size_t expected_avail{single_heap_.get_size() - expected_used};
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
single_heap_.free(ptr);
expected_used = 0;
ASSERT_EQ(single_heap_.get_used(), expected_used);
expected_avail = single_heap_.get_size();
ASSERT_EQ(single_heap_.get_avail(), expected_avail);
}
+43
Visa fil
@@ -0,0 +1,43 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_SINGLE_HEAP_GTEST_HPP
#define ROCSHMEM_SINGLE_HEAP_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/single_heap.hpp"
namespace rocshmem {
class SingleHeapTestFixture : public ::testing::Test
{
protected:
/**
* @brief Single heap object
*/
SingleHeap single_heap_ {};
};
} // namespace rocshmem
#endif // ROCSHMEM_SINGLE_HEAP_GTEST_HPP
+130
Visa fil
@@ -0,0 +1,130 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "slab_heap_gtest.hpp"
using namespace rocshmem;
TEST_F(SlabHeapTestFixture, malloc_free) {
void *ptr{nullptr};
size_t request_bytes{48};
auto slab{slab_.get()};
slab->malloc(&ptr, request_bytes);
ASSERT_NE(ptr, nullptr);
ASSERT_NO_FATAL_FAILURE(slab->free(ptr));
}
TEST_F(SlabHeapTestFixture, overallocate_2GiB) {
void *ptr{nullptr};
size_t request_bytes{1UL << 31};
auto slab{slab_.get()};
slab->malloc(&ptr, request_bytes);
ASSERT_EQ(ptr, nullptr);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_1) {
run_all_threads_once(1, 1);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_2_1) {
run_all_threads_once(2, 1);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_64_1) {
run_all_threads_once(64, 1);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_128_1) {
run_all_threads_once(128, 1);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_256_1) {
run_all_threads_once(256, 1);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_512_1) {
run_all_threads_once(512, 1);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1024_1) {
run_all_threads_once(1024, 1);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_2) {
run_all_threads_once(1, 2);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_8) {
run_all_threads_once(1, 8);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_64) {
run_all_threads_once(1, 64);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_128) {
run_all_threads_once(1, 128);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_256) {
run_all_threads_once(1, 256);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_1024) {
run_all_threads_once(1, 1024);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_2048) {
run_all_threads_once(1, 2048);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_4096) {
run_all_threads_once(1, 4096);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_8192) {
run_all_threads_once(1, 8192);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1_65536) {
run_all_threads_once(1, 65536);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_2_2) {
run_all_threads_once(2, 2);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_64_2) {
run_all_threads_once(64, 2);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_256_50) {
run_all_threads_once(256, 50);
}
TEST_F(SlabHeapTestFixture, run_all_threads_once_1024_512) {
run_all_threads_once(1024, 512);
}
+113
Visa fil
@@ -0,0 +1,113 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_SLAB_HEAP_GTEST_HPP
#define ROCSHMEM_SLAB_HEAP_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/slab_heap.hpp"
#include "../src/util.hpp"
namespace rocshmem {
/**
* @brief Datatype used by test
*/
using TYPE = uint32_t;
/**
* @brief The bit pattern written to memory by each thread.
*/
static const TYPE THREAD_VALUE {0xAA};
inline __device__
void
write_to_memory(TYPE* raw_memory) {
auto thread_idx {get_flat_block_id()};
raw_memory[thread_idx] = THREAD_VALUE;
__threadfence();
}
inline __device__
TYPE*
allocate_memory(SlabHeap* slab) {
auto block_size {get_flat_block_size()};
TYPE* dyn_arr {nullptr};
size_t num_bytes {block_size * sizeof(TYPE)};
slab->malloc(reinterpret_cast<void**>(&dyn_arr), num_bytes);
return dyn_arr;
}
__global__
void
all_threads_once(SlabHeap* slab) {
auto block_mem {allocate_memory(slab)};
write_to_memory(block_mem);
}
class SlabHeapTestFixture : public ::testing::Test {
using SLAB_PROXY_T = SlabHeapProxy<HIPAllocator>;
public:
void
run_all_threads_once(uint32_t x_block_dim,
uint32_t x_grid_dim) {
auto slab {slab_.get()};
const dim3 hip_blocksize(x_block_dim, 1, 1);
const dim3 hip_gridsize(x_grid_dim, 1, 1);
hipLaunchKernelGGL(all_threads_once,
hip_gridsize,
hip_blocksize,
0,
nullptr,
slab);
hipError_t return_code = hipStreamSynchronize(nullptr);
if (return_code != hipSuccess) {
printf("Failed in stream synchronize\n");
assert(return_code == hipSuccess);
}
TYPE* ptr {reinterpret_cast<TYPE*>(slab->get_base_ptr())};
size_t number_threads {x_block_dim * x_grid_dim};
for (size_t i {0}; i < number_threads; i++) {
ASSERT_EQ(ptr[i], THREAD_VALUE);
}
}
protected:
/**
* @brief Slab heap object
*/
SLAB_PROXY_T slab_ {};
};
} // namespace rocshmem
#endif // ROCSHMEM_SLAB_HEAP_GTEST_HPP
@@ -0,0 +1,69 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "spin_ebo_block_mutex_gtest.hpp"
using namespace rocshmem;
/*****************************************************************************
******************************* Fixture Tests *******************************
*****************************************************************************/
TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_1) {
run_all_threads_once(1, 1);
}
TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_2) {
run_all_threads_once(1, 2);
}
TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_8) {
run_all_threads_once(1, 8);
}
TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_64) {
run_all_threads_once(1, 64);
}
TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_128) {
run_all_threads_once(1, 128);
}
TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_256) {
run_all_threads_once(1, 256);
}
TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_1024) {
run_all_threads_once(1, 1024);
}
TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_2048) {
run_all_threads_once(1, 2048);
}
// TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_4096) {
// run_all_threads_once(1, 4096);
//}
// TEST_F(SpinEBOBlockMutexTestFixture, run_all_threads_once_1_8192) {
// run_all_threads_once(1, 8192);
//}
@@ -0,0 +1,140 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_SPIN_EBO_BLOCK_MUTEX_GTEST_HPP
#define ROCSHMEM_SPIN_EBO_BLOCK_MUTEX_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/hip_allocator.hpp"
#include "../src/sync/spin_ebo_block_mutex.hpp"
#include "../src/util.hpp"
namespace rocshmem {
inline __device__
void
increment_counter(SpinEBOBlockMutex *mutex,
size_t *counter) {
mutex->lock();
(*counter)++;
__threadfence();
mutex->unlock();
}
__global__
void
all_threads_once(SpinEBOBlockMutex *mutex,
size_t *counter) {
increment_counter(mutex, counter);
}
__global__
void
block_leader_once(SpinEBOBlockMutex *mutex,
size_t *counter) {
if (is_thread_zero_in_block()) {
increment_counter(mutex, counter);
}
}
__global__
void
warp_leader_once(SpinEBOBlockMutex *mutex,
size_t *counter) {
if (is_thread_zero_in_wave()) {
increment_counter(mutex, counter);
}
}
class SpinEBOBlockMutexTestFixture : public ::testing::Test {
public:
SpinEBOBlockMutexTestFixture() {
assert(mutex_ == nullptr);
hip_allocator_.allocate((void**)&mutex_, sizeof(SpinEBOBlockMutex));
assert(mutex_);
new (mutex_) SpinEBOBlockMutex(true);
assert(counter_ == nullptr);
hip_allocator_.allocate((void**)&counter_, sizeof(int));
assert(counter_);
*counter_ = 0;
}
~SpinEBOBlockMutexTestFixture() {
if (mutex_) {
hip_allocator_.deallocate(mutex_);
}
if (counter_) {
hip_allocator_.deallocate(counter_);
}
}
void
run_all_threads_once(uint32_t x_block_dim,
uint32_t x_grid_dim) {
const dim3 hip_blocksize(x_block_dim, 1, 1);
const dim3 hip_gridsize(x_grid_dim, 1, 1);
hipLaunchKernelGGL(all_threads_once,
hip_gridsize,
hip_blocksize,
0,
nullptr,
mutex_,
counter_);
hipError_t return_code = hipStreamSynchronize(nullptr);
if (return_code != hipSuccess) {
printf("Failed in stream synchronize\n");
assert(return_code == hipSuccess);
}
size_t number_threads {x_block_dim * x_grid_dim};
ASSERT_EQ(*counter_, number_threads);
}
protected:
/**
* @brief An allocator to create objects in device memory.
*/
HIPAllocator hip_allocator_ {};
/**
* @brief A mutex to prevent data races.
*/
SpinEBOBlockMutex *mutex_ {nullptr};
/**
* @brief A monotonically increasing counter to track accesses.
*/
size_t *counter_ {nullptr};
};
} // namespace rocshmem
#endif // ROCSHMEM_SPIN_EBO_BLOCK_MUTEX_GTEST_HPP
+52
Visa fil
@@ -0,0 +1,52 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#include "symmetric_heap_gtest.hpp"
using namespace rocshmem;
TEST_F(SymmetricHeapTestFixture, malloc_free) {
void *ptr{nullptr};
size_t request_bytes{48};
symmetric_heap_.malloc(&ptr, request_bytes);
ASSERT_NE(ptr, nullptr);
ASSERT_NO_FATAL_FAILURE(symmetric_heap_.free(ptr));
}
TEST_F(SymmetricHeapTestFixture, window_info) {
auto win_info_ptr{symmetric_heap_.get_window_info()};
void *window_base_addr{nullptr};
int flag{0};
MPI_Win_get_attr(win_info_ptr->get_win(), MPI_WIN_BASE, &window_base_addr,
&flag);
ASSERT_NE(0, flag);
ASSERT_NE(nullptr, window_base_addr);
}
TEST_F(SymmetricHeapTestFixture, heap_bases) {
auto heap_bases{symmetric_heap_.get_heap_bases()};
for (const auto &base : heap_bases) {
ASSERT_NE(nullptr, base);
}
}
+43
Visa fil
@@ -0,0 +1,43 @@
/******************************************************************************
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*****************************************************************************/
#ifndef ROCSHMEM_SYMMETRIC_HEAP_GTEST_HPP
#define ROCSHMEM_SYMMETRIC_HEAP_GTEST_HPP
#include "gtest/gtest.h"
#include "../src/memory/symmetric_heap.hpp"
namespace rocshmem {
class SymmetricHeapTestFixture : public ::testing::Test
{
protected:
/**
* @brief Symmetric heap object
*/
SymmetricHeap symmetric_heap_ {};
};
} // namespace rocshmem
#endif // ROCSHMEM_SYMMETRIC_HEAP_GTEST_HPP