| 32 | vec3i computeGrid(int num); |
| 33 | |
| 34 | int main(int argc, char **argv) |
| 35 | { |
| 36 | int mpiThreadCapability = 0; |
| 37 | MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &mpiThreadCapability); |
| 38 | if (mpiThreadCapability != MPI_THREAD_MULTIPLE |
| 39 | && mpiThreadCapability != MPI_THREAD_SERIALIZED) { |
| 40 | fprintf(stderr, |
| 41 | "OSPRay requires the MPI runtime to support thread " |
| 42 | "multiple or thread serialized.\n"); |
| 43 | return 1; |
| 44 | } |
| 45 | |
| 46 | std::string sceneName = "gravity_spheres_volume"; |
| 47 | if (argc == 2) { |
| 48 | sceneName = argv[1]; |
| 49 | } |
| 50 | |
| 51 | int mpiRank = 0; |
| 52 | int mpiWorldSize = 0; |
| 53 | MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank); |
| 54 | MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); |
| 55 | |
| 56 | std::cout << "OSPRay rank " << mpiRank << "/" << mpiWorldSize << "\n"; |
| 57 | |
| 58 | // load the MPI module, and select the MPI distributed device. Here we |
| 59 | // do not call ospInit, as we want to explicitly pick the distributed |
| 60 | // device |
| 61 | auto OSPRAY_MPI_DISTRIBUTED_GPU = |
| 62 | utility::getEnvVar<int>("OSPRAY_MPI_DISTRIBUTED_GPU").value_or(0); |
| 63 | if (OSPRAY_MPI_DISTRIBUTED_GPU) { |
| 64 | ospLoadModule("mpi_distributed_gpu"); |
| 65 | } else { |
| 66 | ospLoadModule("mpi_distributed_cpu"); |
| 67 | } |
| 68 | |
| 69 | { |
| 70 | cpp::Device mpiDevice("mpiDistributed"); |
| 71 | mpiDevice.commit(); |
| 72 | mpiDevice.setCurrent(); |
| 73 | |
| 74 | // set an error callback to catch any OSPRay errors and exit the application |
| 75 | mpiDevice.setErrorCallback( |
| 76 | [](void *, OSPError error, const char *errorDetails) { |
| 77 | std::cerr << "OSPRay error: " << errorDetails << std::endl; |
| 78 | exit(error); |
| 79 | }); |
| 80 | |
| 81 | // Regions are assigned to ranks in 3D grid, determine which brick of the |
| 82 | // grid is owned by this rank |
| 83 | const vec3i distribGrid = computeGrid(mpiWorldSize); |
| 84 | const vec3i distribBrickId(mpiRank % distribGrid.x, |
| 85 | (mpiRank / distribGrid.x) % distribGrid.y, |
| 86 | mpiRank / (distribGrid.x * distribGrid.y)); |
| 87 | |
| 88 | std::cout << "scene = " << sceneName << "\n"; |
| 89 | auto builder = testing::newBuilder(sceneName); |
| 90 | testing::setParam(builder, "rendererType", "scivis"); |
| 91 | testing::commit(builder); |
nothing calls this directly
no test coverage detected