Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(FetchContent)
set(KOKKOS_FETCH_TAG "5.1.1" CACHE STRING "Kokkos git tag to fetch")
find_package(Kokkos 5.1.1 QUIET)
if (NOT Kokkos_FOUND)
message(STATUS "Kokkos not found locally - fetching tag " "${KOKKOS_FETCH_TAG} via FetchContent")
message(STATUS "Kokkos not found locally - fetching tag ${KOKKOS_FETCH_TAG} via FetchContent")
FetchContent_Declare(kokkos GIT_REPOSITORY https://github.com/kokkos/kokkos.git GIT_TAG ${KOKKOS_FETCH_TAG} GIT_SHALLOW ON)
FetchContent_MakeAvailable(kokkos)
else()
Expand Down
8 changes: 1 addition & 7 deletions kokkos_tree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
cmake_minimum_required(VERSION 3.21)
include(GoogleTest)
if(NOT PROJECT_NAME)
project(test_dyn_rank CXX)
set(CMAKE_CXX_STANDARD 20)
find_package(Kokkos 5.1.1 REQUIRED)

enable_testing()
endif()

add_executable(Kokkos_qun_test test_dyn_rank.cpp)
target_link_libraries(Kokkos_qun_test PRIVATE Kokkos::kokkos GTest::gtest)

add_test(
NAME Kokkos_qun_test
COMMAND Kokkos_qun_test
)
add_test(NAME Kokkos_qun_test COMMAND Kokkos_qun_test)
1 change: 1 addition & 0 deletions kokkos_tree/desul/Compare_Exchange_Cuda.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

12 changes: 12 additions & 0 deletions kokkos_tree/desul/desul_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,16 @@ TEST(DesulAtomicTest, CmpExchFailureOrder_TypeMapping) {
desul::Impl::cmpexch_failure_memory_order<desul::MemoryOrderSeqCst>,
desul::MemoryOrderSeqCst>::value));
}
TEST(DesulNumericLimitsTest,atomics_include_desul_atomics_Common_hpp_L82 ){
constexpr uint32_t desul_max = desul::Impl::numeric_limits_max<uint32_t>::value;
constexpr uint32_t std_max = std::numeric_limits<uint32_t>::max();
EXPECT_EQ(desul_max, std_max) << "Doesn't match";
constexpr uint64_t desul_max64 = desul::Impl::numeric_limits_max<uint64_t>::value;
constexpr uint64_t std_max64 = std::numeric_limits<uint64_t>::max();
EXPECT_EQ(desul_max64, std_max64) << "Doesn't match";
Comment on lines +66 to +71
auto val = sizeof(int64_t);
EXPECT_EQ(val, 8) << "Doesn't match";
ASSERT_TRUE((std::is_same_v<desul::Impl::atomic_compare_exchange_t<int64_t>, int64_t>)) << "Doesn't match";
}
Comment on lines +65 to +75

} // namespace Test
112 changes: 112 additions & 0 deletions kokkos_tree/kokkos_core/cuda_Error.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#include <gtest/gtest.h>
#include <Kokkos_Core.hpp>
#include <Cuda/Kokkos_Cuda_Error.hpp>
#include <stdexcept>
#include <type_traits> // That's for std::is_void_v
#include <cuda_runtime_api.h>
#include <Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp>
namespace Test{
TEST(KokkosCudaError, InternalErrorThrowsRuntimeError){
EXPECT_THROW({
Kokkos::Impl::cuda_internal_error_throw(cudaErrorInvalidValue,"PlasmaKernal",__FILE__,__LINE__);
}, std::runtime_error);
}
struct InternalCudaFunctor{
Kokkos::View<int*,Kokkos::CudaSpace> data;
InternalCudaFunctor(Kokkos::View<int*,Kokkos::CudaSpace> d):data(d){}
KOKKOS_INLINE_FUNCTION void operator()(const int i) const{
data(i) = i * 2;
}
};

TEST(Kokkos_internal, InterCudaFunctorCase01){
const int N=100000;
using CudaPolicy = Kokkos::RangePolicy<Kokkos::Cuda>;
Kokkos::View<int*,Kokkos::CudaSpace> data("data",N);
Kokkos::parallel_for("TestCudaInternal",CudaPolicy(0,N),InternalCudaFunctor(data));
Kokkos::fence();
auto h_data = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),data);
for(int i=0;i<N;i++){
EXPECT_EQ(h_data(i),i*2)<<"Kernel exec failed at index "<<i;
}
}
TEST(Kokkos_internal, InterCudaFunctorCase02){
const int N= 1028;
Kokkos::View<int*,Kokkos::CudaSpace> data("data",N);
using CudaPolicy = Kokkos::RangePolicy<Kokkos::Cuda>;
using Functor = InternalCudaFunctor;
CudaPolicy policy(0,N);
Functor functor(data);
using ImplParallelFor = Kokkos::Impl::ParallelFor<Functor,CudaPolicy,Kokkos::Cuda>;
ImplParallelFor impl_parallel_for(functor,policy);
impl_parallel_for.execute();
Kokkos::Cuda().fence("Wait for internal launch to finish");
auto h_data = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),data);
for(int i=0;i<N;i++){
EXPECT_EQ(h_data(i),i*2)<<"Kernel exec failed at index "<<i;
}
}
struct SpecialTag {};
struct TagDispatchFunctor{
Kokkos::View<int*,Kokkos::CudaSpace> data;
TagDispatchFunctor(Kokkos::View<int*,Kokkos::CudaSpace> d):data(d){}
KOKKOS_INLINE_FUNCTION void operator()(const int i) const{
data(i) = i * 2;
}
KOKKOS_INLINE_FUNCTION void operator()(const SpecialTag&,const int i) const{
data(i) = i * 3;
}
};
TEST(kokkos_internal, InterCudaFunctorCase03){
const int N = 12800;
using KView = Kokkos::View<int*,Kokkos::CudaSpace>;
using ImplParallelFor = Kokkos::Impl::ParallelFor<TagDispatchFunctor,Kokkos::RangePolicy<Kokkos::Cuda>,Kokkos::Cuda>;
using CudaPolicy = ImplParallelFor::Policy;
KView d("data",N);
ImplParallelFor imppf(TagDispatchFunctor(d),CudaPolicy(0,N));
imppf.execute();
Kokkos::Cuda().fence("Wait for void tag launch");
auto h_data = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), d);
for(int i = 0; i < N; ++i) {
EXPECT_EQ(h_data(i), i * 2) << "Void overload failed!";
}
}
TEST(kokkos_internal, CudaWarpAllocationGranularity){
cudaDeviceProp prop;
prop.major = 8;
prop.minor = 6;
EXPECT_EQ(Kokkos::Impl::cuda_warp_per_sm_allocation_granularity(prop), 4u) << "Expected 4 warps per SM for Ampere";
prop.major = 6;
prop.minor = 0;
EXPECT_EQ(Kokkos::Impl::cuda_warp_per_sm_allocation_granularity(prop), 2u) << "Expected 2 warps per SM for Pascal";
prop.major = 6;
prop.minor = 1;
EXPECT_EQ(Kokkos::Impl::cuda_warp_per_sm_allocation_granularity(prop), 4u) << "Expected 4 warps per SM for Pascal";
prop.major = 23;
prop.minor = 0;
EXPECT_THROW({Kokkos::Impl::cuda_warp_per_sm_allocation_granularity(prop);},std::runtime_error) << "Expected runtime error for unknown architecture";
}
TEST(kokkos_internal, CudaBlockSizeDeduction){
cudaDeviceProp prop;
prop.major = 8;
prop.sharedMemPerBlockOptin = 100000;
prop.reservedSharedMemPerBlock = 1024;
size_t shrd_mem = Kokkos::Impl::get_max_shared_mem_per_block(prop);
EXPECT_EQ(shrd_mem, 98976) << "Shared memory per block calculation failed for Ampere";
}
TEST(kokkos_internal, CudaMaxWarpPerSmRegisters){
cudaDeviceProp prop;
cudaFuncAttributes attr;
prop.major = 8;
prop.minor = 6;
prop.warpSize = 32;
prop.regsPerBlock = 65536;
attr.numRegs = 32;
int optimal_wraps = Kokkos::Impl::cuda_max_warps_per_sm_registers(prop,attr);
EXPECT_EQ(optimal_warps, 64)<< "Expected 32 warps per SM for Ampere with 32 registers per thread";
attr.numRegs = 64;
int optimal_wraps = Kokkos::Impl::cuda_max_warps_per_sm_registers(prop,attr);
EXPECT_EQ(optimal_warps, 32)<< "Expected 16 warps per SM for Ampere with 64 registers per thread";

}
}
1 change: 1 addition & 0 deletions kokkos_tree/test_dyn_rank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "kokkos_core/kokkos_pair_investigation.hpp"
#include "mdspan/kokkos_raw_mdspan.hpp"
#include "kokkos_core/test_drank.hpp"
#include "kokkos_core/cuda_Error.hpp"
#include <Kokkos_Core.hpp>
Comment on lines 3 to 6
#include <gtest/gtest.h>
int main(int argc, char **argv) {
Expand Down
Loading