Cleanup unused code in repository (#75)
* Remove unused forward_list * Remove unused __read_clock function * Replace wallClk code with hip function * Remove unused unit test for ipc * Remove slab heap * Remove unused EBO spinlock
This commit is contained in:
@@ -80,17 +80,13 @@ target_sources(
|
||||
address_record_gtest.cpp
|
||||
index_strategy_gtest.cpp
|
||||
single_heap_gtest.cpp
|
||||
#slab_heap_gtest.cpp # Test is disabled because class unused
|
||||
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
|
||||
#context_ipc_gtest.cpp
|
||||
wavefront_size_gtest.cpp
|
||||
atomic_wf_queue_gtest.cpp
|
||||
)
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/******************************************************************************
|
||||
* 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 "context_ipc_gtest.hpp"
|
||||
|
||||
using namespace rocshmem;
|
||||
|
||||
TEST_F(ContextIpcTestFixture, constructor) {
|
||||
/* do nothing for the moment, I *think* the
|
||||
** constructor is invoked automatically
|
||||
*/
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/******************************************************************************
|
||||
* 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_CONTEXT_IPC_GTEST_HPP
|
||||
#define ROCSHMEM_CONTEXT_IPC_GTEST_HPP
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "../src/ipc/context_ipc_device.hpp"
|
||||
#include "../src/ipc/backend_ipc.hpp"
|
||||
|
||||
namespace rocshmem {
|
||||
|
||||
class ContextIpcTestFixture : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* @brief Context Ipc Test
|
||||
*/
|
||||
IPCBackend be{MPI_COMM_WORLD};
|
||||
|
||||
IPCContext ipc_context_ {&be};
|
||||
};
|
||||
|
||||
} // namespace rocshmem
|
||||
|
||||
#endif // ROCSHMEM_CONTEXT_IPC_GTEST_HPP
|
||||
@@ -1,51 +0,0 @@
|
||||
/******************************************************************************
|
||||
* 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';
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/******************************************************************************
|
||||
* 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
|
||||
@@ -1,130 +0,0 @@
|
||||
/******************************************************************************
|
||||
* 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);
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/******************************************************************************
|
||||
* 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
|
||||
@@ -1,69 +0,0 @@
|
||||
/******************************************************************************
|
||||
* 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);
|
||||
//}
|
||||
@@ -1,140 +0,0 @@
|
||||
/******************************************************************************
|
||||
* 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
|
||||
Reference in New Issue
Block a user