| 53 | } |
| 54 | |
| 55 | int main(int argc, char **argv) |
| 56 | { |
| 57 | for (int i = 1; i < argc; ++i) { |
| 58 | std::string arg = argv[i]; |
| 59 | if (arg == "-h" || arg == "--help") { |
| 60 | printHelp(); |
| 61 | return 0; |
| 62 | } else if (arg == "-r" || arg == "--renderer") { |
| 63 | rendererType = argv[++i]; |
| 64 | } else if (arg == "-s" || arg == "--scene") { |
| 65 | builderType = argv[++i]; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | int mpiThreadCapability = 0; |
| 70 | MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &mpiThreadCapability); |
| 71 | if (mpiThreadCapability != MPI_THREAD_MULTIPLE |
| 72 | && mpiThreadCapability != MPI_THREAD_SERIALIZED) { |
| 73 | fprintf(stderr, |
| 74 | "OSPRay requires the MPI runtime to support thread " |
| 75 | "multiple or thread serialized.\n"); |
| 76 | return 1; |
| 77 | } |
| 78 | |
| 79 | int mpiRank = 0; |
| 80 | int mpiWorldSize = 0; |
| 81 | MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank); |
| 82 | MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); |
| 83 | |
| 84 | std::cout << "OSPRay rank " << mpiRank << "/" << mpiWorldSize << "\n"; |
| 85 | |
| 86 | // load the MPI module, and select the MPI distributed device. Here we |
| 87 | // do not call ospInit, as we want to explicitly pick the distributed |
| 88 | // device |
| 89 | auto OSPRAY_MPI_DISTRIBUTED_GPU = |
| 90 | utility::getEnvVar<int>("OSPRAY_MPI_DISTRIBUTED_GPU").value_or(0); |
| 91 | if (OSPRAY_MPI_DISTRIBUTED_GPU) { |
| 92 | ospLoadModule("mpi_distributed_gpu"); |
| 93 | } else { |
| 94 | ospLoadModule("mpi_distributed_cpu"); |
| 95 | } |
| 96 | |
| 97 | { |
| 98 | cpp::Device mpiDevice("mpiDistributed"); |
| 99 | mpiDevice.commit(); |
| 100 | mpiDevice.setCurrent(); |
| 101 | |
| 102 | // set an error callback to catch any OSPRay errors and exit the application |
| 103 | ospDeviceSetErrorCallback( |
| 104 | mpiDevice.handle(), |
| 105 | [](void *, OSPError error, const char *errorDetails) { |
| 106 | std::cerr << "OSPRay error: " << errorDetails << std::endl; |
| 107 | exit(error); |
| 108 | }, |
| 109 | nullptr); |
| 110 | |
| 111 | auto builder = testing::newBuilder(builderType); |
| 112 | testing::setParam(builder, "rendererType", rendererType); |
nothing calls this directly
no test coverage detected