Skip to content

Passing an MPI communicator #143

@keceli

Description

@keceli

We should be able to pass an MPI communicator to NWChemEx runtime. I tested this for PluginPlay and TiledArray I didn't see any issue, but with TensorWrapper, I get:

Allocator<Scalar>
  allocate(rank 1 tensor)
-------------------------------------------------------------------------------
/home/keceli/soft/nwx/TensorWrapper/tests/tensor/allocators/allocator.cpp:63
...............................................................................

/home/keceli/soft/nwx/TensorWrapper/tests/tensor/allocators/allocator.cpp:63: FAILED:
due to a fatal error condition:
  SIGSEGV - Segmentation violation signal

Here is the only change I made to pass the already initialized communicator:

> diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index bfd05e2..cd47124 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -20,7 +20,19 @@
 #include <parallelzone/runtime/runtime_view.hpp>

 int main(int argc, char* argv[]) {
-    auto rt = parallelzone::runtime::RuntimeView(argc, argv);
+    // Initialize MPI
+    int provided, rank, size;
+    MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+    // Create a new communicator for each rank
+    MPI_Comm new_comm;
+    MPI_Comm_split(MPI_COMM_WORLD, rank, 0, &new_comm);
+
+    auto rt = parallelzone::runtime::RuntimeView(argc, argv, new_comm);
+
+    //auto rt = parallelzone::runtime::RuntimeView(argc, argv);

     int res = Catch::Session().run(argc, argv);

Note that, it gives the seg fault even with a single rank, i.e. when I just run `./test_tensorwrapper. However, this issue still could be related to #142.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions