Created
June 29, 2024 21:37
-
-
Save vicentebolea/a8c44fd49d3c2c952f81a2a9c7ce2554 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM opensuse/tumbleweed | |
| LABEL maintainer "Vicente Adolfo Bolea Sanchez<[email protected]>" | |
| # Base dependencies for building VTK-m projects | |
| RUN zypper refresh && \ | |
| zypper update -y && \ | |
| zypper install -y --no-recommends \ | |
| cmake \ | |
| gcc \ | |
| gcc-c++ \ | |
| glew-devel \ | |
| make \ | |
| mpich-devel \ | |
| Mesa-libGL-devel \ | |
| vtk-m-mpich-devel \ | |
| && \ | |
| zypper clean --all | |
| RUN mkdir /root/repr | |
| RUN cat <<EOF > /root/repr/reproducer.cpp | |
| #include <mpi.h> | |
| #include <vtkm/cont/ArrayHandle.h> | |
| #include <vtkm/cont/EnvironmentTracker.h> | |
| #include <vtkm/cont/Initialize.h> | |
| VTKM_THIRDPARTY_PRE_INCLUDE | |
| #include <vtkm/thirdparty/diy/diy.h> | |
| VTKM_THIRDPARTY_POST_INCLUDE | |
| void test_all_to_all(void*, const vtkmdiy::ReduceProxy& rp) | |
| { | |
| auto selfid = rp.gid(); | |
| if (rp.in_link().size() == 0) | |
| { | |
| for (int cc = 0; cc < rp.out_link().size(); ++cc) | |
| { | |
| auto target = rp.out_link().target(cc); | |
| if (target.gid != selfid) | |
| { | |
| std::cout << "Block " << rp.gid() << " send to block " << target.gid << ": "; | |
| #ifdef USE_STL_ARRAY | |
| std::vector<vtkm::Id> testVector({ 3, 4, 2 }); | |
| for (auto x : testVector) std::cout << x << " "; | |
| std::cout << std::endl; | |
| rp.enqueue(target, testVector); | |
| #else | |
| vtkm::cont::ArrayHandle<vtkm::Id> testArrayHandle = | |
| vtkm::cont::make_ArrayHandle<vtkm::Id>({ 3, 4, 2 }); | |
| vtkm::cont::printSummary_ArrayHandle(testArrayHandle, std::cout, true); | |
| rp.enqueue(target, testArrayHandle); | |
| #endif | |
| } | |
| } | |
| } | |
| else | |
| { | |
| for (int i = 0; i < rp.in_link().size(); ++i) | |
| { | |
| int ingid = rp.in_link().target(i).gid; | |
| if (ingid == selfid) | |
| continue; | |
| std::cout << "Receiving data from block " << ingid << ": "; | |
| #ifdef USE_STL_ARRAY | |
| std::vector<vtkm::Id> testVector; | |
| rp.dequeue(ingid, testVector); | |
| for (auto x : testVector) std::cout << x << " "; | |
| std::cout << std::endl; | |
| #else | |
| vtkm::cont::ArrayHandle<vtkm::Id> testArrayHandle; | |
| rp.dequeue(ingid, testArrayHandle); | |
| vtkm::cont::printSummary_ArrayHandle(testArrayHandle, std::cout, true); | |
| #endif | |
| } | |
| } | |
| } | |
| int main(int argc, char** argv) | |
| { | |
| MPI_Init(&argc, &argv); | |
| // initialize vtkm-m (e.g., logging via -v and device via the -d option) | |
| vtkm::cont::InitializeOptions vtkm_initialize_options = | |
| vtkm::cont::InitializeOptions::DefaultAnyDevice; | |
| vtkm::cont::InitializeResult vtkm_config = | |
| vtkm::cont::Initialize(argc, argv, vtkm_initialize_options); | |
| auto comm = vtkm::cont::EnvironmentTracker::GetCommunicator(); | |
| auto rank = comm.rank(); | |
| auto size = comm.size(); | |
| vtkmdiy::Master master(comm, 1, -1); | |
| int n_blocks = 4; | |
| vtkmdiy::ContiguousAssigner assigner(size, n_blocks); | |
| std::vector<int> local_gids; | |
| assigner.local_gids(rank, local_gids); | |
| struct DummyBlock {}; | |
| //for (int i =0; i < n_blocks; ++i) master.add(i, new DummyBlock, new vtkmdiy::Link); | |
| for (int gid : local_gids) | |
| { | |
| std::cout << "Rank " << rank << " adding block with gid " << gid << std::endl; | |
| master.add(gid, new DummyBlock, new vtkmdiy::Link); | |
| }; | |
| std::cout << "All_to_all:" << std::endl; | |
| vtkmdiy::all_to_all(master, assigner, &test_all_to_all); | |
| } | |
| EOF | |
| RUN cat <<EOF > /root/repr/CMakeLists.txt | |
| cmake_minimum_required(VERSION 3.12 FATAL_ERROR) | |
| project(repr CXX) | |
| find_package(VTKm REQUIRED) | |
| add_executable(repr reproducer.cpp) | |
| target_link_libraries(repr PRIVATE vtkm::cont) | |
| EOF | |
| WORKDIR /root | |
| RUN source /usr/lib64/mpi/gcc/mpich/bin/mpivars.sh && \ | |
| CXX=mpic++ cmake -B build -S repr && \ | |
| cmake build -DCMAKE_CXX_FLAGS="-DUSE_STL_ARRAY" && \ | |
| cmake --build build && \ | |
| ./build/repr && \ | |
| cmake build -DCMAKE_CXX_FLAGS="" && \ | |
| cmake --build build && \ | |
| ./build/repr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment