From bd57405ccb5befe9769d6e1c8b1a9b5faaa9e307 Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Tue, 21 Feb 2023 16:52:57 -0500 Subject: [PATCH] kokkos,cmake: remove kokkosview example --- examples/CMakeLists.txt | 9 -- examples/kokkos/CMakeLists.txt | 13 --- examples/kokkos/kokkosWriteRead.cpp | 172 ---------------------------- 3 files changed, 194 deletions(-) delete mode 100644 examples/kokkos/CMakeLists.txt delete mode 100644 examples/kokkos/kokkosWriteRead.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index aabb35cc07..12e7b32a3f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,12 +22,3 @@ endif() if(ADIOS2_HAVE_CUDA OR ADIOS2_HAVE_Kokkos_CUDA) add_subdirectory(cuda) endif() - -if(ADIOS2_HAVE_Kokkos) - add_subdirectory(kokkos) -elseif(ADIOS2_HAVE_CUDA) - find_package(Kokkos QUIET) - if(Kokkos_FOUND) - add_subdirectory(kokkos) - endif() -endif() diff --git a/examples/kokkos/CMakeLists.txt b/examples/kokkos/CMakeLists.txt deleted file mode 100644 index 32f199a9b2..0000000000 --- a/examples/kokkos/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -add_executable(KokkosWriteRead kokkosWriteRead.cpp) -target_link_libraries(KokkosWriteRead PUBLIC adios2::cxx11 Kokkos::kokkos) - -if(Kokkos_ENABLE_CUDA) - set_property(TARGET KokkosWriteRead PROPERTY CUDA_STANDARD 17) - set_property(SOURCE kokkosWriteRead.cpp PROPERTY LANGUAGE CUDA) - set_property(SOURCE kokkosWriteRead.cpp APPEND PROPERTY COMPILE_FLAGS "--extended-lambda") -endif() diff --git a/examples/kokkos/kokkosWriteRead.cpp b/examples/kokkos/kokkosWriteRead.cpp deleted file mode 100644 index d92f58253f..0000000000 --- a/examples/kokkos/kokkosWriteRead.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Simple example of writing and reading data - * through ADIOS2 BP engine with multiple simulations steps - * for every IO step. - */ - -#include -#include -#include - -#include -#include -#include - -#define ASSERT(condition, message) \ - do \ - { \ - if (!(condition)) \ - { \ - std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \ - << " line " << __LINE__ << ": " << message << std::endl; \ - std::terminate(); \ - } \ - } while (false) - -int BPWrite(const std::string fname, const size_t N, size_t nSteps, - const std::string engine) -{ - int rank, size; -#if ADIOS2_USE_MPI - int provided; - MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); -#else - rank = 0; - size = 1; -#endif - // Initialize the simulation data - using mem_space = Kokkos::DefaultExecutionSpace::memory_space; - Kokkos::View gpuSimData("simBuffer", N); - if (rank == 0) - { - Kokkos::DefaultExecutionSpace exe_space; - std::cout << "Write 6k floats with " << engine - << " on memory space: " << exe_space.name() << std::endl; - } - -#if ADIOS2_USE_MPI - adios2::ADIOS adios(MPI_COMM_WORLD); -#else - adios2::ADIOS adios; -#endif - adios2::IO io = adios.DeclareIO("WriteKokkos"); - io.SetEngine(engine); - - // Declare an array for the ADIOS data of size (NumOfProcesses * N) - const adios2::Dims shape{static_cast(size * N)}; - const adios2::Dims start{static_cast(rank * N)}; - const adios2::Dims count{N}; - auto data = io.DefineVariable("data", shape, start, count); - - adios2::Engine bpWriter = io.Open(fname, adios2::Mode::Write); - - // Simulation steps - for (size_t step = 0; step < nSteps; ++step) - { - // Make a 1D selection to describe the local dimensions of the - // variable we write and its offsets in the global spaces - adios2::Box sel({0}, {N}); - data.SetSelection(sel); - - // Start IO step every write step - bpWriter.BeginStep(); - bpWriter.Put(data, gpuSimData); - bpWriter.EndStep(); - - // Update values in the simulation data - Kokkos::parallel_for( - "updateBuffer", - Kokkos::RangePolicy(0, N), - KOKKOS_LAMBDA(int i) { gpuSimData(i) += 5; }); - } - - bpWriter.Close(); - return 0; -} - -int BPRead(const std::string fname, const size_t N, size_t nSteps, - std::string engine) -{ - int rank; -#if ADIOS2_USE_MPI - int provided; - MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); -#else - rank = 0; -#endif - // Create ADIOS structures -#if ADIOS2_USE_MPI - adios2::ADIOS adios(MPI_COMM_WORLD); -#else - adios2::ADIOS adios; -#endif - adios2::IO io = adios.DeclareIO("ReadKokkos"); - io.SetEngine("BPFile"); - - adios2::Engine bpReader = io.Open(fname, adios2::Mode::Read); - - unsigned int step = 0; - if (rank == 0) - { - Kokkos::DefaultExecutionSpace exe_space; - std::cout << "Read 6k floats with " << engine - << " on memory space: " << exe_space.name() << std::endl; - } - - using mem_space = Kokkos::DefaultExecutionSpace::memory_space; - Kokkos::View gpuSimData("simBuffer", N); - for (; bpReader.BeginStep() == adios2::StepStatus::OK; ++step) - { - auto data = io.InquireVariable("data"); - const adios2::Dims start{rank * N}; - const adios2::Dims count{N}; - const adios2::Box sel(start, count); - data.SetSelection(sel); - - bpReader.Get(data, gpuSimData); - bpReader.EndStep(); - auto simData = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, - gpuSimData); - ASSERT(simData.size() == 6000, - "Rank [" + std::to_string(rank) + - "] Received different data size than expected"); - ASSERT(simData[0] == step * 5, - "[Rank " + std::to_string(rank) + "] Received incorrect data"); - } - bpReader.Close(); - std::cout << "[Rank " << rank << "] Transfer ended successfully" - << std::endl; - return 0; -} - -int main(int argc, char **argv) -{ - const std::vector list_of_engines = {"BPFile", "BP5"}; - const size_t N = 6000; - size_t nSteps = 10; - int ret = 0, rank = 0; -#if ADIOS2_USE_MPI - int provided; - MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); -#endif - Kokkos::initialize(argc, argv); - { - for (auto engine : list_of_engines) - { - const std::string fname(engine + "Kokkos.bp"); - ret += BPWrite(fname, N, nSteps, engine); - ret += BPRead(fname, N, nSteps, engine); - } - } - Kokkos::finalize(); - if (ret == 0 && rank == 0) - std::cout << "All transfered finished successfully. Done" << std::endl; -#if ADIOS2_USE_MPI - MPI_Finalize(); -#endif - return ret; -}