Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "PerProcessorRayTracingResultsVectorPostprocessor.h" 11 : 12 : // Local includes 13 : #include "RayTracingStudy.h" 14 : 15 : #include "TraceRay.h" 16 : #include "ParallelRayStudy.h" 17 : 18 : registerMooseObject("RayTracingApp", PerProcessorRayTracingResultsVectorPostprocessor); 19 : 20 : InputParameters 21 18 : PerProcessorRayTracingResultsVectorPostprocessor::validParams() 22 : { 23 18 : InputParameters params = GeneralVectorPostprocessor::validParams(); 24 : 25 18 : params.addClassDescription( 26 : "Accumulates ray tracing results (information about the trace) on a per-processor basis."); 27 : 28 36 : params.addRequiredParam<UserObjectName>("study", "The RayTracingStudy to get results from"); 29 : 30 : const std::string result_names = 31 : "rays_started rays_traced chunks_traced rays_received buffers_received rays_sent " 32 : "buffers_sent intersections generation_time propagation_time num_probes ray_pool_created " 33 : "receive_ray_pool_created receive_buffer_pool_created send_buffer_pool_created face_hit " 34 : "vertex_hit edge_hit moved_through_neighbors backface_culling_successes " 35 : "backface_culling_failures intersection_calls vertex_neighbor_builds vertex_neighbor_lookups " 36 18 : "edge_neighbor_builds edge_neighbor_lookups point_neighbor_builds failed_traces"; 37 36 : MultiMooseEnum results(result_names, result_names); 38 : 39 36 : params.addParam<MultiMooseEnum>("results", results, "The selection of results you want reported"); 40 : 41 18 : return params; 42 18 : } 43 : 44 9 : PerProcessorRayTracingResultsVectorPostprocessor::PerProcessorRayTracingResultsVectorPostprocessor( 45 9 : const InputParameters & parameters) 46 : : GeneralVectorPostprocessor(parameters), 47 9 : _study(getUserObject<RayTracingStudy>("study")), 48 18 : _results(getParam<MultiMooseEnum>("results")), 49 9 : _pid(processor_id()), 50 18 : _pid_values(declareVector("pid")) 51 : { 52 : auto num_procs = n_processors(); 53 : 54 9 : _pid_values.resize(num_procs, 0); 55 : 56 261 : for (auto & result : _results) 57 : { 58 : std::string lower_result_name; 59 : 60 252 : std::transform(result.name().begin(), 61 : result.name().end(), 62 : std::back_inserter(lower_result_name), 63 : ::tolower); 64 : 65 252 : auto id = result.id(); 66 : 67 252 : _result_values[id] = &declareVector(lower_result_name); 68 : 69 252 : _result_values[id]->resize(num_procs, 0); 70 : } 71 9 : } 72 : 73 : void 74 8 : PerProcessorRayTracingResultsVectorPostprocessor::initialize() 75 : { 76 8 : } 77 : 78 : void 79 8 : PerProcessorRayTracingResultsVectorPostprocessor::execute() 80 : { 81 8 : _pid_values[_pid] = _pid; 82 : 83 232 : for (auto & result : _results) 84 : { 85 224 : switch (result) 86 : { 87 8 : case 0: // rays_started 88 8 : (*_result_values[0])[_pid] = _study.parallelRayStudy().localWorkStarted(); 89 8 : break; 90 8 : case 1: // rays_traced 91 8 : (*_result_values[1])[_pid] = _study.parallelRayStudy().localWorkExecuted(); 92 8 : break; 93 8 : case 2: // chunks_traced 94 8 : (*_result_values[2])[_pid] = _study.parallelRayStudy().localChunksExecuted(); 95 8 : break; 96 8 : case 3: // rays_received 97 8 : (*_result_values[3])[_pid] = _study.parallelRayStudy().receiveBuffer().objectsReceived(); 98 8 : break; 99 8 : case 4: // buffers_received 100 8 : (*_result_values[4])[_pid] = _study.parallelRayStudy().receiveBuffer().buffersReceived(); 101 8 : break; 102 8 : case 5: // rays_sent 103 8 : (*_result_values[5])[_pid] = _study.parallelRayStudy().parallelDataSent(); 104 8 : break; 105 8 : case 6: // buffers_sent 106 8 : (*_result_values[6])[_pid] = _study.parallelRayStudy().buffersSent(); 107 8 : break; 108 8 : case 7: // intersections 109 8 : (*_result_values[7])[_pid] = _study.localTraceRayResult(TraceRay::INTERSECTIONS); 110 8 : break; 111 8 : case 8: // generation_time 112 8 : (*_result_values[8])[_pid] = _study.generationTime(); 113 8 : break; 114 8 : case 9: // propagation_time 115 8 : (*_result_values[9])[_pid] = _study.propagationTime(); 116 8 : break; 117 8 : case 10: // num_probes 118 8 : (*_result_values[10])[_pid] = _study.parallelRayStudy().receiveBuffer().numProbes(); 119 8 : break; 120 8 : case 11: // ray_pool_created 121 16 : (*_result_values[11])[_pid] = _study.parallelRayStudy().poolParallelDataCreated(); 122 8 : break; 123 8 : case 12: // receive_ray_pool_created 124 8 : (*_result_values[12])[_pid] = _study.parallelRayStudy().receiveBuffer().objectPoolCreated(); 125 8 : break; 126 8 : case 13: // receive_buffer_pool_created 127 8 : (*_result_values[13])[_pid] = _study.parallelRayStudy().receiveBuffer().bufferPoolCreated(); 128 8 : break; 129 8 : case 14: // send_buffer_pool_created 130 8 : (*_result_values[14])[_pid] = _study.parallelRayStudy().sendBufferPoolCreated(); 131 8 : break; 132 8 : case 15: // face_hit 133 8 : (*_result_values[15])[_pid] = _study.localTraceRayResult(TraceRay::FACE_HITS); 134 8 : break; 135 8 : case 16: // vertex_hit 136 8 : (*_result_values[16])[_pid] = _study.localTraceRayResult(TraceRay::VERTEX_HITS); 137 8 : break; 138 8 : case 17: // edge_hit 139 8 : (*_result_values[17])[_pid] = _study.localTraceRayResult(TraceRay::EDGE_HITS); 140 8 : break; 141 8 : case 18: // moved_through_neighbors 142 8 : (*_result_values[18])[_pid] = _study.localTraceRayResult(TraceRay::MOVED_THROUGH_NEIGHBORS); 143 8 : break; 144 8 : case 19: // backface_culling_successes 145 8 : (*_result_values[19])[_pid] = 146 8 : _study.localTraceRayResult(TraceRay::BACKFACE_CULLING_SUCCESSES); 147 8 : break; 148 8 : case 20: // backface_culling_failures 149 8 : (*_result_values[20])[_pid] = 150 8 : _study.localTraceRayResult(TraceRay::BACKFACE_CULLING_FAILURES); 151 8 : break; 152 8 : case 21: // intersection_calls 153 8 : (*_result_values[21])[_pid] = _study.localTraceRayResult(TraceRay::INTERSECTION_CALLS); 154 8 : break; 155 8 : case 22: // vertex_neighbor_builds 156 8 : (*_result_values[22])[_pid] = _study.localTraceRayResult(TraceRay::VERTEX_NEIGHBOR_BUILDS); 157 8 : break; 158 8 : case 23: // vertex_neighbor_lookups 159 8 : (*_result_values[23])[_pid] = _study.localTraceRayResult(TraceRay::VERTEX_NEIGHBOR_LOOKUPS); 160 8 : break; 161 8 : case 24: // edge_neighbor_builds 162 8 : (*_result_values[24])[_pid] = _study.localTraceRayResult(TraceRay::EDGE_NEIGHBOR_BUILDS); 163 8 : break; 164 8 : case 25: // edge_neighbor_lookups 165 8 : (*_result_values[25])[_pid] = _study.localTraceRayResult(TraceRay::EDGE_NEIGHBOR_LOOKUPS); 166 8 : break; 167 8 : case 26: // point_neighbor_builds 168 8 : (*_result_values[26])[_pid] = _study.localTraceRayResult(TraceRay::POINT_NEIGHBOR_BUILDS); 169 8 : break; 170 8 : case 27: // failed_traces 171 8 : (*_result_values[27])[_pid] = _study.localTraceRayResult(TraceRay::FAILED_TRACES); 172 8 : break; 173 0 : default: 174 0 : mooseError("Unknown result type '", 175 : result.name(), 176 : "/", 177 : result.id(), 178 : "' in PerProcessorRayTracingResultsVectorPostprocessor ", 179 : name()); 180 : } 181 : } 182 8 : } 183 : 184 : void 185 8 : PerProcessorRayTracingResultsVectorPostprocessor::finalize() 186 : { 187 : // TODO: Should be able to just "gather" to proc zero - but that's not working.... 188 8 : gatherMax(_pid_values); 189 : 190 232 : for (auto & result : _results) 191 224 : gatherMax(*_result_values[result.id()]); 192 8 : }