MCPcopy Create free account
hub / github.com/RenderKit/ospray / main

Function main

modules/mpi/tutorials/ospMPIDistribTutorialReplicated.cpp:55–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55int 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);

Callers

nothing calls this directly

Calls 12

printHelpFunction · 0.85
ospLoadModuleFunction · 0.85
newBuilderFunction · 0.85
setParamFunction · 0.85
buildWorldFunction · 0.85
setCurrentMethod · 0.80
commitFunction · 0.50
releaseFunction · 0.50
commitMethod · 0.45
handleMethod · 0.45
mainLoopMethod · 0.45

Tested by

no test coverage detected