From dc2c03755ed7bda0ca805445f802c748144796f7 Mon Sep 17 00:00:00 2001 From: Jacob Moore Date: Tue, 10 Sep 2024 09:47:52 -0500 Subject: [PATCH] ENH: Add get_name functionality to kokkos types --- examples/mtr-kokkos-simple.cpp | 8 +- src/include/kokkos_types.h | 216 +++++++++++++++++++++++++- test/test_cases/test_CArrayKokkos.cpp | 27 +++- 3 files changed, 246 insertions(+), 5 deletions(-) diff --git a/examples/mtr-kokkos-simple.cpp b/examples/mtr-kokkos-simple.cpp index 4cf79c9f..b6a9d11b 100644 --- a/examples/mtr-kokkos-simple.cpp +++ b/examples/mtr-kokkos-simple.cpp @@ -126,8 +126,12 @@ int main(int argc, char *argv[]) { // Matrix examples following the Fortran index convention, // indicies go from 1 to N, first index varies the fastest - FMatrixDevice matrix1D(10); // declare and allocate a 1D matrix of size 10 - FMatrixDevice matrix2D(10,10); // declare and allocate a 2D matrix with sizes of 10 x 10 + FMatrixDevice matrix1D(10, "1D_FMatrix"); // declare and allocate a 1D matrix of size 10 + FMatrixDevice matrix2D(10,10, "2D_FMatrix"); // declare and allocate a 2D matrix with sizes of 10 x 10 + + std::cout<< "Name of 1D Matrix = "<(sizes[0], sizes[1], sizes[2], sizes[3], sizes[4], sizes[5], "A_7D_CArrayKokkos"); + A = CArrayKokkos(sizes[0], sizes[1], sizes[2], sizes[3], sizes[4], sizes[5], "A_6D_CArrayKokkos"); } else if(dims == 7){ A = CArrayKokkos(sizes[0], sizes[1], sizes[2], sizes[3], sizes[4], sizes[5], sizes[6], "A_7D_CArrayKokkos"); @@ -108,7 +108,7 @@ TEST(Test_CArrayKokkos, order) } -// Test order function +// Test pointer function TEST(Test_CArrayKokkos, pointer) { std::vector sizes; @@ -123,6 +123,29 @@ TEST(Test_CArrayKokkos, pointer) } } +// Test get name function +TEST(Test_CArrayKokkos, names) +{ + std::vector sizes; + std::vector names = { + "A_1D_CArrayKokkos", + "A_2D_CArrayKokkos", + "A_3D_CArrayKokkos", + "A_4D_CArrayKokkos", + "A_5D_CArrayKokkos", + "A_6D_CArrayKokkos", + "A_7D_CArrayKokkos" + }; + + for(int i = 0; i < 7; i++){ + + int dims = i+1; + sizes.push_back(dims*2); + CArrayKokkos A = return_CArrayKokkos(dims, sizes); + EXPECT_EQ(names[i], A.get_name()); + } +} + // Add test for late initialization TEST(Test_CArrayKokkos, late_init) {