Skip to content
Snippets Groups Projects
Commit 99ffd8ca authored by Lukas Werner's avatar Lukas Werner
Browse files

Change handling of non-MPI builds

parent 5715fc07
Branches
Tags
No related merge requests found
......@@ -107,6 +107,7 @@ struct MPI_Status
int MPI_ERROR;
};
typedef void (MPI_User_function) (void * a, void * b, int * len, MPI_Datatype * );
const int MPI_COMM_NULL = 0;
......@@ -265,6 +266,11 @@ inline int MPI_Error_string ( int, char*, int* ) { WALBERLA_MPI_FUNCTION_ERROR }
inline double MPI_Wtime() { WALBERLA_MPI_FUNCTION_ERROR }
inline int MPI_Op_create(MPI_User_function*, int, MPI_Op*) { WALBERLA_MPI_FUNCTION_ERROR };
inline int MPI_Type_create_struct(int, const int[], MPI_Aint[], MPI_Datatype[], MPI_Datatype*) { WALBERLA_MPI_FUNCTION_ERROR };
inline int MPI_Type_create_resized(MPI_Datatype, MPI_Aint, MPI_Aint, MPI_Datatype*) { WALBERLA_MPI_FUNCTION_ERROR };
int MPI_Type_commit(MPI_Datatype*) { WALBERLA_MPI_FUNCTION_ERROR };
#undef WALBERLA_MPI_FUNCTION_ERROR
} // namespace mpistubs
......
......@@ -20,12 +20,12 @@
#include "Raytracer.h"
#include "geometry/structured/extern/lodepng.h"
#include "core/mpi/all.h"
namespace walberla {
namespace pe {
namespace raytracing {
#ifdef WALBERLA_BUILD_WITH_MPI
void BodyIntersectionInfo_Comparator_MPI_OP( BodyIntersectionInfo *in, BodyIntersectionInfo *inout, int *len, MPI_Datatype *dptr) {
WALBERLA_UNUSED(dptr);
for (int i = 0; i < *len; ++i) {
......@@ -48,7 +48,6 @@ void BodyIntersectionInfo_Comparator_MPI_OP( BodyIntersectionInfo *in, BodyInter
inout++;
}
}
#endif
/*!\brief Instantiation constructor for the Raytracer class.
*
......@@ -100,7 +99,9 @@ Raytracer::Raytracer(const shared_ptr<BlockStorage> forest, const BlockDataID st
setupView_();
setupFilenameRankWidth_();
setupMPI_();
WALBERLA_MPI_SECTION() {
setupMPI_();
}
}
/*!\brief Instantiation constructor for the Raytracer class using a config object for view setup.
......@@ -181,7 +182,9 @@ Raytracer::Raytracer(const shared_ptr<BlockStorage> forest, const BlockDataID st
setupView_();
setupFilenameRankWidth_();
setupMPI_();
WALBERLA_MPI_SECTION() {
setupMPI_();
}
}
/*!\brief Utility function for setting up the view plane and calculating required variables.
......@@ -207,16 +210,13 @@ void Raytracer::setupView_() {
/*!\brief Utility function for initializing the attribute filenameRankWidth.
*/
void Raytracer::setupFilenameRankWidth_() {
WALBERLA_MPI_SECTION() {
int numProcesses = mpi::MPIManager::instance()->numProcesses();
filenameRankWidth_ = uint8_c(log10(numProcesses)+1);
}
int numProcesses = mpi::MPIManager::instance()->numProcesses();
filenameRankWidth_ = uint8_c(log10(numProcesses)+1);
}
/*!\brief Utility function for setting up the MPI datatype and operation.
*/
void Raytracer::setupMPI_() {
#ifdef WALBERLA_BUILD_WITH_MPI
MPI_Op_create((MPI_User_function *)BodyIntersectionInfo_Comparator_MPI_OP, true, &bodyIntersectionInfo_reduction_op);
const int nblocks = 7;
......@@ -247,7 +247,6 @@ void Raytracer::setupMPI_() {
MPI_Type_create_resized( tmp_type, lb, extent, &bodyIntersectionInfo_mpi_type );
MPI_Type_commit(&bodyIntersectionInfo_mpi_type);
#endif
}
/*!\brief Generates the filename for output files.
......@@ -338,7 +337,12 @@ void Raytracer::writeImageToFile(const std::vector<BodyIntersectionInfo>& inters
* \attention This function only works on MPI builds due to the explicit usage of MPI routines.
*/
void Raytracer::syncImageUsingMPIReduce(std::vector<BodyIntersectionInfo>& intersectionsBuffer, WcTimingTree* tt) {
#ifdef WALBERLA_BUILD_WITH_MPI
WALBERLA_NON_MPI_SECTION() {
WALBERLA_UNUSED(intersectionsBuffer);
WALBERLA_UNUSED(tt);
WALBERLA_ABORT("Cannot call MPI reduce on a non-MPI build due to usage of MPI-specific code.");
}
WALBERLA_MPI_BARRIER();
if (tt != NULL) tt->start("Reduction");
int rank = mpi::MPIManager::instance()->rank();
......@@ -357,11 +361,6 @@ void Raytracer::syncImageUsingMPIReduce(std::vector<BodyIntersectionInfo>& inter
WALBERLA_MPI_BARRIER();
if (tt != NULL) tt->stop("Reduction");
#else
WALBERLA_UNUSED(intersectionsBuffer);
WALBERLA_UNUSED(tt);
WALBERLA_ABORT("Cannot call MPI reduce on a non-MPI build due to usage of MPI-specific code.");
#endif
}
/*!\brief Conflate the intersectionsBuffer of each process onto the root process using MPI_Gather.
......
......@@ -35,9 +35,6 @@
#include "pe/ccd/ICCD.h"
#include <pe/ccd/HashGrids.h>
#include "core/mpi/MPIManager.h"
#include "core/mpi/MPIWrapper.h"
#include "core/mpi/all.h"
#include <stddef.h>
using namespace walberla::pe;
......@@ -156,10 +153,8 @@ private:
real_t pixelHeight_; //!< The height of a pixel of the generated image in the viewing plane.
//@}
#ifdef WALBERLA_BUILD_WITH_MPI
MPI_Op bodyIntersectionInfo_reduction_op;
MPI_Datatype bodyIntersectionInfo_mpi_type;
#endif
public:
/*!\name Get functions */
......@@ -647,8 +642,7 @@ void Raytracer::generateImage(const size_t timestep, WcTimingTree* tt) {
syncImageUsingMPIGather(intersections, intersectionsBuffer, tt);
break;
}
}
WALBERLA_NON_MPI_SECTION() {
} else {
syncImageUsingMPIGather(intersections, intersectionsBuffer, tt);
}
......
......@@ -352,7 +352,6 @@ void RaytracerSpheresTestScene(Raytracer::Algorithm raytracingAlgorithm = Raytra
Vec3(-5,5,5), Vec3(-1,5,5), Vec3(0,0,1), //-5,5,5; -1,5,5
lighting,
Color(real_t(0.2),real_t(0.2),real_t(0.2)),
real_t(2),
customSpheresBodyToShadingParams);
MaterialID iron = Material::find("iron");
......@@ -535,7 +534,6 @@ void HashGridsTest(Raytracer::Algorithm raytracingAlgorithm, uint8_t antiAliasFa
std::get<2>(vector),
lighting0,
Color(real_t(0.2),real_t(0.2),real_t(0.2)),
real_t(2),
customHashGridsBodyToShadingParams);
raytracer.setImageOutputEnabled(true);
raytracer.setFilenameTimestepWidth(12);
......@@ -579,7 +577,6 @@ void raytraceArtifactsForest(Raytracer::Algorithm raytracingAlgorithm, uint8_t a
upVector,
lighting,
Color(real_t(0.2),real_t(0.2),real_t(0.2)),
real_t(2),
customArtifactsBodyToShadingParams);
raytracer.setImageOutputEnabled(true);
raytracer.setFilenameTimestepWidth(timestepWidth);
......@@ -818,8 +815,7 @@ void HashGridsTestScene(Raytracer::Algorithm raytracingAlgorithm = Raytracer::RA
std::get<1>(vector),
std::get<2>(vector),
lighting,
Color(real_t(0.2),real_t(0.2),real_t(0.2)),
real_t(2));
Color(real_t(0.2),real_t(0.2),real_t(0.2)));
raytracer.setRaytracingAlgorithm(raytracingAlgorithm);
raytracer.setImageOutputEnabled(true);
......@@ -855,6 +851,7 @@ int main( int argc, char** argv )
RaytracerTest(algorithm, antiAliasFactor);
//RaytracerSpheresTestScene(algorithm, antiAliasFactor);
HashGridsTestScene(algorithm, antiAliasFactor);
HashGridsTest(algorithm, antiAliasFactor,
50, 30, 130,
10);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment