Fixing compile errors without MPI, modifying build flags
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "IO/MeshDatabase.h"
|
||||
#include "IO/Mesh.h"
|
||||
#include "IO/IOHelpers.h"
|
||||
#include "IO/MPIHelpers.h"
|
||||
#include "common/MPI.h"
|
||||
#include "common/Utilities.h"
|
||||
|
||||
#include <vector>
|
||||
@@ -10,53 +10,50 @@
|
||||
#include <ProfilerApp.h>
|
||||
|
||||
|
||||
namespace IO {
|
||||
|
||||
|
||||
|
||||
/****************************************************
|
||||
* Pack/unpack data from a buffer *
|
||||
****************************************************/
|
||||
// MeshType
|
||||
template<>
|
||||
size_t packsize<MeshType>( const MeshType& rhs )
|
||||
size_t packsize<IO::MeshType>( const IO::MeshType& rhs )
|
||||
{
|
||||
return sizeof(MeshType);
|
||||
return sizeof(IO::MeshType);
|
||||
}
|
||||
template<>
|
||||
void pack<MeshType>( const MeshType& rhs, char *buffer )
|
||||
void pack<IO::MeshType>( const IO::MeshType& rhs, char *buffer )
|
||||
{
|
||||
memcpy(buffer,&rhs,sizeof(MeshType));
|
||||
memcpy(buffer,&rhs,sizeof(IO::MeshType));
|
||||
}
|
||||
template<>
|
||||
void unpack<MeshType>( MeshType& data, const char *buffer )
|
||||
void unpack<IO::MeshType>( IO::MeshType& data, const char *buffer )
|
||||
{
|
||||
memcpy(&data,buffer,sizeof(MeshType));
|
||||
memcpy(&data,buffer,sizeof(IO::MeshType));
|
||||
}
|
||||
// Variable::VariableType
|
||||
template<>
|
||||
size_t packsize<VariableType>( const VariableType& rhs )
|
||||
size_t packsize<IO::VariableType>( const IO::VariableType& rhs )
|
||||
{
|
||||
return sizeof(VariableType);
|
||||
return sizeof(IO::VariableType);
|
||||
}
|
||||
template<>
|
||||
void pack<VariableType>( const VariableType& rhs, char *buffer )
|
||||
void pack<IO::VariableType>( const IO::VariableType& rhs, char *buffer )
|
||||
{
|
||||
memcpy(buffer,&rhs,sizeof(MeshType));
|
||||
memcpy(buffer,&rhs,sizeof(IO::VariableType));
|
||||
}
|
||||
template<>
|
||||
void unpack<VariableType>( VariableType& data, const char *buffer )
|
||||
void unpack<IO::VariableType>( IO::VariableType& data, const char *buffer )
|
||||
{
|
||||
memcpy(&data,buffer,sizeof(MeshType));
|
||||
memcpy(&data,buffer,sizeof(IO::VariableType));
|
||||
}
|
||||
// DatabaseEntry
|
||||
template<>
|
||||
size_t packsize<DatabaseEntry>( const DatabaseEntry& rhs )
|
||||
size_t packsize<IO::DatabaseEntry>( const IO::DatabaseEntry& rhs )
|
||||
{
|
||||
return packsize(rhs.name)+packsize(rhs.file)+packsize(rhs.offset);
|
||||
}
|
||||
template<>
|
||||
void pack<DatabaseEntry>( const DatabaseEntry& rhs, char *buffer )
|
||||
void pack<IO::DatabaseEntry>( const IO::DatabaseEntry& rhs, char *buffer )
|
||||
{
|
||||
size_t i=0;
|
||||
pack(rhs.name,&buffer[i]); i+=packsize(rhs.name);
|
||||
@@ -64,7 +61,7 @@ void pack<DatabaseEntry>( const DatabaseEntry& rhs, char *buffer )
|
||||
pack(rhs.offset,&buffer[i]); i+=packsize(rhs.offset);
|
||||
}
|
||||
template<>
|
||||
void unpack<DatabaseEntry>( DatabaseEntry& data, const char *buffer )
|
||||
void unpack<IO::DatabaseEntry>( IO::DatabaseEntry& data, const char *buffer )
|
||||
{
|
||||
size_t i=0;
|
||||
unpack(data.name,&buffer[i]); i+=packsize(data.name);
|
||||
@@ -73,12 +70,12 @@ void unpack<DatabaseEntry>( DatabaseEntry& data, const char *buffer )
|
||||
}
|
||||
// VariableDatabase
|
||||
template<>
|
||||
size_t packsize<VariableDatabase>( const VariableDatabase& rhs )
|
||||
size_t packsize<IO::VariableDatabase>( const IO::VariableDatabase& rhs )
|
||||
{
|
||||
return packsize(rhs.name)+packsize(rhs.type)+packsize(rhs.dim);
|
||||
}
|
||||
template<>
|
||||
void pack<VariableDatabase>( const VariableDatabase& rhs, char *buffer )
|
||||
void pack<IO::VariableDatabase>( const IO::VariableDatabase& rhs, char *buffer )
|
||||
{
|
||||
size_t i=0;
|
||||
pack(rhs.name,&buffer[i]); i+=packsize(rhs.name);
|
||||
@@ -86,7 +83,7 @@ void pack<VariableDatabase>( const VariableDatabase& rhs, char *buffer )
|
||||
pack(rhs.dim,&buffer[i]); i+=packsize(rhs.dim);
|
||||
}
|
||||
template<>
|
||||
void unpack<VariableDatabase>( VariableDatabase& data, const char *buffer )
|
||||
void unpack<IO::VariableDatabase>( IO::VariableDatabase& data, const char *buffer )
|
||||
{
|
||||
size_t i=0;
|
||||
unpack(data.name,&buffer[i]); i+=packsize(data.name);
|
||||
@@ -95,7 +92,7 @@ void unpack<VariableDatabase>( VariableDatabase& data, const char *buffer )
|
||||
}
|
||||
// MeshDatabase
|
||||
template<>
|
||||
size_t packsize<MeshDatabase>( const MeshDatabase& data )
|
||||
size_t packsize<IO::MeshDatabase>( const IO::MeshDatabase& data )
|
||||
{
|
||||
return packsize(data.name)
|
||||
+ packsize(data.type)
|
||||
@@ -106,7 +103,7 @@ size_t packsize<MeshDatabase>( const MeshDatabase& data )
|
||||
+ packsize(data.variable_data);
|
||||
}
|
||||
template<>
|
||||
void pack<MeshDatabase>( const MeshDatabase& rhs, char *buffer )
|
||||
void pack<IO::MeshDatabase>( const IO::MeshDatabase& rhs, char *buffer )
|
||||
{
|
||||
size_t i = 0;
|
||||
pack(rhs.name,&buffer[i]); i+=packsize(rhs.name);
|
||||
@@ -118,7 +115,7 @@ void pack<MeshDatabase>( const MeshDatabase& rhs, char *buffer )
|
||||
pack(rhs.variable_data,&buffer[i]); i+=packsize(rhs.variable_data);
|
||||
}
|
||||
template<>
|
||||
void unpack<MeshDatabase>( MeshDatabase& data, const char *buffer )
|
||||
void unpack<IO::MeshDatabase>( IO::MeshDatabase& data, const char *buffer )
|
||||
{
|
||||
size_t i=0;
|
||||
unpack(data.name,&buffer[i]); i+=packsize(data.name);
|
||||
@@ -131,6 +128,9 @@ void unpack<MeshDatabase>( MeshDatabase& data, const char *buffer )
|
||||
}
|
||||
|
||||
|
||||
namespace IO {
|
||||
|
||||
|
||||
/****************************************************
|
||||
* VariableDatabase *
|
||||
****************************************************/
|
||||
@@ -239,70 +239,72 @@ void DatabaseEntry::read( const std::string& line )
|
||||
// Gather the mesh databases from all processors
|
||||
std::vector<MeshDatabase> gatherAll( const std::vector<MeshDatabase>& meshes, MPI_Comm comm )
|
||||
{
|
||||
PROFILE_START("gatherAll");
|
||||
int rank = -1;
|
||||
int size = 0;
|
||||
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
|
||||
MPI_Comm_size( MPI_COMM_WORLD, &size );
|
||||
// First pack the mesh data to local buffers
|
||||
size_t localsize = 0;
|
||||
for (size_t i=0; i<meshes.size(); i++)
|
||||
localsize += packsize(meshes[i]);
|
||||
char *localbuf = new char[localsize];
|
||||
size_t pos = 0;
|
||||
for (size_t i=0; i<meshes.size(); i++) {
|
||||
pack( meshes[i], &localbuf[pos] );
|
||||
pos += packsize(meshes[i]);
|
||||
}
|
||||
// Get the number of bytes each processor will be sending/recieving
|
||||
int sendsize = static_cast<int>(localsize);
|
||||
int *recvsize = new int[size];
|
||||
MPI_Allgather(&sendsize,1,MPI_INT,recvsize,1,MPI_INT,comm);
|
||||
size_t globalsize = recvsize[0];
|
||||
int *disp = new int[size];
|
||||
disp[0] = 0;
|
||||
for (int i=1; i<size; i++) {
|
||||
disp[i] = disp[i-1] + recvsize[i];
|
||||
globalsize += recvsize[i];
|
||||
}
|
||||
// Send/recv the global data
|
||||
char *globalbuf = new char[globalsize];
|
||||
MPI_Allgatherv(localbuf,sendsize,MPI_CHAR,globalbuf,recvsize,disp,MPI_CHAR,comm);
|
||||
// Unpack the data
|
||||
std::map<std::string,MeshDatabase> data;
|
||||
pos = 0;
|
||||
while ( pos < globalsize ) {
|
||||
MeshDatabase tmp;
|
||||
unpack(tmp,&globalbuf[pos]);
|
||||
pos += packsize(tmp);
|
||||
std::map<std::string,MeshDatabase>::iterator it = data.find(tmp.name);
|
||||
if ( it==data.end() ) {
|
||||
data[tmp.name] = tmp;
|
||||
} else {
|
||||
for (size_t i=0; i<tmp.domains.size(); i++)
|
||||
it->second.domains.push_back(tmp.domains[i]);
|
||||
for (size_t i=0; i<tmp.variables.size(); i++)
|
||||
it->second.variables.push_back(tmp.variables[i]);
|
||||
it->second.variable_data.insert(tmp.variable_data.begin(),tmp.variable_data.end());
|
||||
#ifdef USE_MPI
|
||||
PROFILE_START("gatherAll");
|
||||
int rank = MPI_WORLD_RANK();
|
||||
int size = MPI_WORLD_SIZE();
|
||||
// First pack the mesh data to local buffers
|
||||
size_t localsize = 0;
|
||||
for (size_t i=0; i<meshes.size(); i++)
|
||||
localsize += packsize(meshes[i]);
|
||||
char *localbuf = new char[localsize];
|
||||
size_t pos = 0;
|
||||
for (size_t i=0; i<meshes.size(); i++) {
|
||||
pack( meshes[i], &localbuf[pos] );
|
||||
pos += packsize(meshes[i]);
|
||||
}
|
||||
}
|
||||
for (std::map<std::string,MeshDatabase>::iterator it=data.begin(); it!=data.end(); ++it) {
|
||||
// Get the unique variables
|
||||
std::set<VariableDatabase> data2(it->second.variables.begin(),it->second.variables.end());
|
||||
it->second.variables = std::vector<VariableDatabase>(data2.begin(),data2.end());
|
||||
}
|
||||
// Free temporary memory
|
||||
delete [] localbuf;
|
||||
delete [] recvsize;
|
||||
delete [] disp;
|
||||
delete [] globalbuf;
|
||||
// Return the results
|
||||
std::vector<MeshDatabase> data2(data.size());
|
||||
size_t i=0;
|
||||
for (std::map<std::string,MeshDatabase>::iterator it=data.begin(); it!=data.end(); ++it, ++i)
|
||||
data2[i] = it->second;
|
||||
PROFILE_STOP("gatherAll");
|
||||
return data2;
|
||||
// Get the number of bytes each processor will be sending/recieving
|
||||
int sendsize = static_cast<int>(localsize);
|
||||
int *recvsize = new int[size];
|
||||
MPI_Allgather(&sendsize,1,MPI_INT,recvsize,1,MPI_INT,comm);
|
||||
size_t globalsize = recvsize[0];
|
||||
int *disp = new int[size];
|
||||
disp[0] = 0;
|
||||
for (int i=1; i<size; i++) {
|
||||
disp[i] = disp[i-1] + recvsize[i];
|
||||
globalsize += recvsize[i];
|
||||
}
|
||||
// Send/recv the global data
|
||||
char *globalbuf = new char[globalsize];
|
||||
MPI_Allgatherv(localbuf,sendsize,MPI_CHAR,globalbuf,recvsize,disp,MPI_CHAR,comm);
|
||||
// Unpack the data
|
||||
std::map<std::string,MeshDatabase> data;
|
||||
pos = 0;
|
||||
while ( pos < globalsize ) {
|
||||
MeshDatabase tmp;
|
||||
unpack(tmp,&globalbuf[pos]);
|
||||
pos += packsize(tmp);
|
||||
std::map<std::string,MeshDatabase>::iterator it = data.find(tmp.name);
|
||||
if ( it==data.end() ) {
|
||||
data[tmp.name] = tmp;
|
||||
} else {
|
||||
for (size_t i=0; i<tmp.domains.size(); i++)
|
||||
it->second.domains.push_back(tmp.domains[i]);
|
||||
for (size_t i=0; i<tmp.variables.size(); i++)
|
||||
it->second.variables.push_back(tmp.variables[i]);
|
||||
it->second.variable_data.insert(tmp.variable_data.begin(),tmp.variable_data.end());
|
||||
}
|
||||
}
|
||||
for (std::map<std::string,MeshDatabase>::iterator it=data.begin(); it!=data.end(); ++it) {
|
||||
// Get the unique variables
|
||||
std::set<VariableDatabase> data2(it->second.variables.begin(),it->second.variables.end());
|
||||
it->second.variables = std::vector<VariableDatabase>(data2.begin(),data2.end());
|
||||
}
|
||||
// Free temporary memory
|
||||
delete [] localbuf;
|
||||
delete [] recvsize;
|
||||
delete [] disp;
|
||||
delete [] globalbuf;
|
||||
// Return the results
|
||||
std::vector<MeshDatabase> data2(data.size());
|
||||
size_t i=0;
|
||||
for (std::map<std::string,MeshDatabase>::iterator it=data.begin(); it!=data.end(); ++it, ++i)
|
||||
data2[i] = it->second;
|
||||
PROFILE_STOP("gatherAll");
|
||||
return data2;
|
||||
#else
|
||||
return meshes;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define MeshDatabase_INC
|
||||
|
||||
#include "IO/Mesh.h"
|
||||
#include "common/MPI.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
@@ -9,12 +10,6 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#ifdef USE_MPI
|
||||
#include "mpi.h"
|
||||
#else
|
||||
typedef int MPI_Comm;
|
||||
#endif
|
||||
|
||||
|
||||
namespace IO {
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "IO/Writer.h"
|
||||
#include "IO/MeshDatabase.h"
|
||||
#include "IO/IOHelpers.h"
|
||||
#include "common/MPI.h"
|
||||
#include "common/Utilities.h"
|
||||
|
||||
#include "mpi.h"
|
||||
#include <sys/stat.h>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
@@ -16,8 +16,7 @@ static bool global_summary_created = false;
|
||||
// Write the mesh data in the original format
|
||||
static std::vector<IO::MeshDatabase> writeMeshesOrigFormat( const std::vector<IO::MeshDataStruct>& meshData, const char* path )
|
||||
{
|
||||
int rank = -1;
|
||||
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
|
||||
int rank = MPI_WORLD_RANK();
|
||||
std::vector<IO::MeshDatabase> meshes_written;
|
||||
for (size_t i=0; i<meshData.size(); i++) {
|
||||
char domainname[100], filename[100], fullpath[200];
|
||||
@@ -78,8 +77,7 @@ static std::vector<IO::MeshDatabase> writeMeshesOrigFormat( const std::vector<IO
|
||||
static IO::MeshDatabase write_domain( FILE *fid, const std::string& filename,
|
||||
const IO::MeshDataStruct& mesh, int format )
|
||||
{
|
||||
int rank = -1;
|
||||
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
|
||||
int rank = MPI_WORLD_RANK();
|
||||
char domainname[10];
|
||||
sprintf(domainname,"%05i",rank);
|
||||
int level = 0;
|
||||
@@ -137,8 +135,7 @@ static IO::MeshDatabase write_domain( FILE *fid, const std::string& filename,
|
||||
static std::vector<IO::MeshDatabase> writeMeshesNewFormat(
|
||||
const std::vector<IO::MeshDataStruct>& meshData, const char* path, int format )
|
||||
{
|
||||
int rank = -1;
|
||||
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
|
||||
int rank = MPI_WORLD_RANK();
|
||||
std::vector<IO::MeshDatabase> meshes_written;
|
||||
char filename[100], fullpath[200];
|
||||
sprintf(filename,"%05i",rank);
|
||||
@@ -156,10 +153,8 @@ static std::vector<IO::MeshDatabase> writeMeshesNewFormat(
|
||||
// Write the mesh data
|
||||
void IO::writeData( int timestep, const std::vector<IO::MeshDataStruct>& meshData, int format )
|
||||
{
|
||||
int rank = -1;
|
||||
int size = 0;
|
||||
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
|
||||
MPI_Comm_size( MPI_COMM_WORLD, &size );
|
||||
int rank = MPI_WORLD_RANK();
|
||||
int size = MPI_WORLD_SIZE();
|
||||
// Create the output directory
|
||||
char path[100];
|
||||
sprintf(path,"vis%03i",timestep);
|
||||
|
||||
20
README.visit
20
README.visit
@@ -6,18 +6,22 @@ Example commands for Rhea:
|
||||
Load the proper modules
|
||||
module load visit
|
||||
module load cmake
|
||||
module load gcc/4.8.2
|
||||
|
||||
Configure cmake to build the plug-in
|
||||
cmake \
|
||||
-D CMAKE_BUILD_TYPE:STRING=Release \
|
||||
-D CMAKE_C_COMPILER:PATH=gcc \
|
||||
-D CMAKE_CXX_COMPILER:PATH=g++ \
|
||||
-D USE_MPI=FALSE \
|
||||
-D USE_CUDA=FALSE \
|
||||
-D USE_VISIT=TRUE \
|
||||
-D VISIT_ROOT_DIR=/sw/rhea/visit \
|
||||
cmake \
|
||||
-D CMAKE_BUILD_TYPE:STRING=Release \
|
||||
-D CMAKE_C_COMPILER:PATH=gcc \
|
||||
-D CMAKE_CXX_COMPILER:PATH=g++ \
|
||||
-D USE_MPI=false \
|
||||
-D USE_CUDA=false \
|
||||
-D USE_VISIT=true \
|
||||
-D VISIT_ROOT_DIR=/sw/rhea/visit \
|
||||
-D USE_TIMER=false \
|
||||
../../LBPM-WIA
|
||||
|
||||
|
||||
|
||||
Build the visit plug-in
|
||||
make visit
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ MACRO( VISIT_PLUGIN SRC_DIR TARGET )
|
||||
ADD_CUSTOM_TARGET(
|
||||
${SRC_DIR}
|
||||
COMMAND ${VISIT_XML_CMAKE} ${TARGET}.xml
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} .
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} .
|
||||
COMMAND make
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${SRC_DIR}"
|
||||
SOURCES ${SRC_DIR}
|
||||
|
||||
@@ -105,6 +105,7 @@ MACRO( CONFIGURE_MPI )
|
||||
ENDIF()
|
||||
# Check if we need to use MPI for serial tests
|
||||
CHECK_ENABLE_FLAG( USE_MPI_FOR_SERIAL_TESTS 0 )
|
||||
SET( MPI_CXXFLAGS -DUSE_MPI -I${MPI_INCLUDE} )
|
||||
# Set the definitions
|
||||
ADD_DEFINITIONS ( "-D USE_MPI" )
|
||||
MESSAGE ( "Using MPI" )
|
||||
|
||||
@@ -174,11 +174,12 @@ MACRO( SET_COMPILER )
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
# Macro to set the proper warnings
|
||||
MACRO ( SET_WARNINGS )
|
||||
# Macro to set the compiler specific flags
|
||||
MACRO ( SET_COMPILER_FLAGS )
|
||||
IF ( USING_GCC )
|
||||
# Add gcc specific compiler options
|
||||
# -Wno-reorder: warning: "" will be initialized after "" when initialized here
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-char-subscripts -Wno-comment -Wno-unused-variable -Wno-unused-but-set-variable")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-char-subscripts -Wno-comment -Wno-unused-variable -Wno-unused-but-set-variable")
|
||||
ELSEIF ( USING_MICROSOFT )
|
||||
@@ -237,7 +238,7 @@ MACRO( SET_COMPILE_FLAGS )
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
|
||||
ENDIF()
|
||||
SET_WARNINGS()
|
||||
SET_COMPILER_FLAGS()
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef COMMUNICATION_H_INC
|
||||
#define COMMUNICATION_H_INC
|
||||
|
||||
#include "common/MPI.h"
|
||||
#include "Array.h"
|
||||
|
||||
// ********** COMMUNICTION **************************************
|
||||
|
||||
@@ -8,8 +8,11 @@
|
||||
#include <time.h>
|
||||
#include <exception> // std::exception
|
||||
#include <stdexcept>
|
||||
#include <mpi.h>
|
||||
|
||||
#include "common/Utilities.h"
|
||||
#include "common/MPI.h"
|
||||
|
||||
|
||||
|
||||
int MAX_BLOB_COUNT=500;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "IO/MPIHelpers.h"
|
||||
#include "common/MPI.h"
|
||||
#include "common/Utilities.h"
|
||||
|
||||
namespace IO {
|
||||
|
||||
|
||||
/********************************************************
|
||||
@@ -104,6 +104,72 @@ void unpack<std::string>( std::string& data, const char *buffer )
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
/********************************************************
|
||||
* Fake MPI routines *
|
||||
********************************************************/
|
||||
#ifndef USE_MPI
|
||||
int MPI_Init(int*,char***)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int MPI_Finalize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int MPI_Comm_size( MPI_Comm, int *size )
|
||||
{
|
||||
*size = 1;
|
||||
return 0;
|
||||
}
|
||||
int MPI_Comm_rank( MPI_Comm, int *rank )
|
||||
{
|
||||
*rank = 1;
|
||||
return 0;
|
||||
}
|
||||
int MPI_Barrier( MPI_Comm )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int MPI_Waitall( int, MPI_Request[], MPI_Status[] )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int MPI_Bcast( void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm )
|
||||
{
|
||||
ERROR("Not implimented yet");
|
||||
return 0;
|
||||
}
|
||||
int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
|
||||
MPI_Comm comm, MPI_Request *request)
|
||||
{
|
||||
ERROR("Not implimented yet");
|
||||
return 0;
|
||||
}
|
||||
int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
|
||||
int tag, MPI_Comm comm, MPI_Request *request)
|
||||
{
|
||||
ERROR("Not implimented yet");
|
||||
return 0;
|
||||
}
|
||||
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
|
||||
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
|
||||
{
|
||||
ERROR("Not implimented yet");
|
||||
return 0;
|
||||
}
|
||||
int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
||||
int dest, int sendtag,
|
||||
void *recvbuf, int recvcount, MPI_Datatype recvtype,
|
||||
int source, int recvtag,
|
||||
MPI_Comm comm, MPI_Status *status)
|
||||
{
|
||||
ERROR("Not implimented yet");
|
||||
return 0;
|
||||
}
|
||||
double MPI_Wtime( void )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
132
common/MPI.h
Normal file
132
common/MPI.h
Normal file
@@ -0,0 +1,132 @@
|
||||
// This file contains wrappers for MPI routines and functions to pack/unpack data structures
|
||||
#ifndef MPI_WRAPPERS_INC
|
||||
#define MPI_WRAPPERS_INC
|
||||
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#ifdef USE_MPI
|
||||
// Inlcude MPI
|
||||
#include "mpi.h"
|
||||
#else
|
||||
// Create fake MPI types
|
||||
typedef int MPI_Comm;
|
||||
typedef int MPI_Request;
|
||||
typedef int MPI_Status;
|
||||
#define MPI_COMM_WORLD 0
|
||||
#define MPI_COMM_SELF 0
|
||||
#define MPI_STATUS_IGNORE NULL
|
||||
enum MPI_Datatype { MPI_LOGICAL, MPI_CHAR, MPI_INT, MPI_DOUBLE };
|
||||
enum MPI_Op { MPI_SUM };
|
||||
// Fake MPI functions
|
||||
int MPI_Init(int*,char***);
|
||||
int MPI_Finalize();
|
||||
int MPI_Comm_size( MPI_Comm, int *size );
|
||||
int MPI_Comm_rank( MPI_Comm, int *rank );
|
||||
int MPI_Barrier(MPI_Comm);
|
||||
int MPI_Waitall(int,MPI_Request[],MPI_Status[]);
|
||||
int MPI_Bcast(void*,int,MPI_Datatype,int,MPI_Comm);
|
||||
int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
|
||||
MPI_Comm comm, MPI_Request *request);
|
||||
int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
|
||||
int tag, MPI_Comm comm, MPI_Request *request);
|
||||
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
|
||||
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
|
||||
int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
|
||||
int dest, int sendtag,
|
||||
void *recvbuf, int recvcount, MPI_Datatype recvtype,
|
||||
int source, int recvtag,
|
||||
MPI_Comm comm, MPI_Status *status);
|
||||
double MPI_Wtime( void );
|
||||
#endif
|
||||
|
||||
|
||||
//! Get the size of MPI_COMM_WORLD
|
||||
inline int MPI_WORLD_SIZE( ) {
|
||||
int size = 1;
|
||||
MPI_Comm_size( MPI_COMM_WORLD, &size );
|
||||
return size;
|
||||
}
|
||||
|
||||
//! Get the size of MPI_COMM_WORLD
|
||||
inline int MPI_WORLD_RANK( ) {
|
||||
int rank = 0;
|
||||
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
|
||||
return rank;
|
||||
}
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a class
|
||||
template<class TYPE>
|
||||
size_t packsize( const TYPE& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void pack( const TYPE& rhs, char *buffer );
|
||||
|
||||
//! Template function to unpack a class from a buffer
|
||||
template<class TYPE>
|
||||
void unpack( TYPE& data, const char *buffer );
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a std::vector
|
||||
template<class TYPE>
|
||||
size_t packsize( const std::vector<TYPE>& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void pack( const std::vector<TYPE>& rhs, char *buffer );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void unpack( std::vector<TYPE>& data, const char *buffer );
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a std::pair
|
||||
template<class TYPE1, class TYPE2>
|
||||
size_t packsize( const std::pair<TYPE1,TYPE2>& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE1, class TYPE2>
|
||||
void pack( const std::pair<TYPE1,TYPE2>& rhs, char *buffer );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE1, class TYPE2>
|
||||
void unpack( std::pair<TYPE1,TYPE2>& data, const char *buffer );
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a std::map
|
||||
template<class TYPE1, class TYPE2>
|
||||
size_t packsize( const std::map<TYPE1,TYPE2>& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE1, class TYPE2>
|
||||
void pack( const std::map<TYPE1,TYPE2>& rhs, char *buffer );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE1, class TYPE2>
|
||||
void unpack( std::map<TYPE1,TYPE2>& data, const char *buffer );
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a std::set
|
||||
template<class TYPE>
|
||||
size_t packsize( const std::set<TYPE>& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void pack( const std::set<TYPE>& rhs, char *buffer );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void unpack( std::set<TYPE>& data, const char *buffer );
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include "common/MPI.hpp"
|
||||
|
||||
|
||||
@@ -1,79 +1,14 @@
|
||||
#ifndef MPI_HELPERS_INC
|
||||
#define MPI_HELPERS_INC
|
||||
// This file contains wrappers for MPI routines and functions to pack/unpack data structures
|
||||
#ifndef MPI_WRAPPERS_HPP
|
||||
#define MPI_WRAPPERS_HPP
|
||||
|
||||
#include "common/MPI.h"
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace IO {
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a class
|
||||
template<class TYPE>
|
||||
size_t packsize( const TYPE& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void pack( const TYPE& rhs, char *buffer );
|
||||
|
||||
//! Template function to unpack a class from a buffer
|
||||
template<class TYPE>
|
||||
void unpack( TYPE& data, const char *buffer );
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a std::vector
|
||||
template<class TYPE>
|
||||
size_t packsize( const std::vector<TYPE>& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void pack( const std::vector<TYPE>& rhs, char *buffer );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void unpack( std::vector<TYPE>& data, const char *buffer );
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a std::pair
|
||||
template<class TYPE1, class TYPE2>
|
||||
size_t packsize( const std::pair<TYPE1,TYPE2>& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE1, class TYPE2>
|
||||
void pack( const std::pair<TYPE1,TYPE2>& rhs, char *buffer );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE1, class TYPE2>
|
||||
void unpack( std::pair<TYPE1,TYPE2>& data, const char *buffer );
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a std::map
|
||||
template<class TYPE1, class TYPE2>
|
||||
size_t packsize( const std::map<TYPE1,TYPE2>& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE1, class TYPE2>
|
||||
void pack( const std::map<TYPE1,TYPE2>& rhs, char *buffer );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE1, class TYPE2>
|
||||
void unpack( std::map<TYPE1,TYPE2>& data, const char *buffer );
|
||||
|
||||
|
||||
//! Template function to return the buffer size required to pack a std::set
|
||||
template<class TYPE>
|
||||
size_t packsize( const std::set<TYPE>& rhs );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void pack( const std::set<TYPE>& rhs, char *buffer );
|
||||
|
||||
//! Template function to pack a class to a buffer
|
||||
template<class TYPE>
|
||||
void unpack( std::set<TYPE>& data, const char *buffer );
|
||||
|
||||
|
||||
|
||||
/********************************************************
|
||||
@@ -216,8 +151,5 @@ void unpack( std::set<TYPE>& data, const char *buffer )
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
#include <mpi.h>
|
||||
|
||||
#include "common/MPI.h"
|
||||
#include "pmmc.h"
|
||||
#include "Domain.h"
|
||||
#include "Extras.h"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
#include <mpi.h>
|
||||
|
||||
#include "pmmc.h"
|
||||
#include "Domain.h"
|
||||
@@ -12,6 +11,7 @@
|
||||
#include "D3Q19.h"
|
||||
#include "D3Q7.h"
|
||||
#include "Color.h"
|
||||
#include "common/MPI.h"
|
||||
#include "Communication.h"
|
||||
#include "IO/Mesh.h"
|
||||
#include "IO/Writer.h"
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
#include <mpi.h>
|
||||
#include <memory>
|
||||
|
||||
#include "common/UnitTest.h"
|
||||
#include "common/Utilities.h"
|
||||
#include "common/MPI.h"
|
||||
#include "IO/MeshDatabase.h"
|
||||
#include "IO/Reader.h"
|
||||
#include "IO/Writer.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include "mpi.h"
|
||||
#include "common/MPI.h"
|
||||
|
||||
|
||||
int main (int argc, char **argv)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
#include <mpi.h>
|
||||
|
||||
#include "pmmc.h"
|
||||
#include "Domain.h"
|
||||
@@ -14,6 +13,8 @@
|
||||
#include "D3Q7.h"
|
||||
#include "Color.h"
|
||||
#include "Communication.h"
|
||||
#include "common/MPI.h"
|
||||
|
||||
|
||||
//#define CBUB
|
||||
#define USE_EXP_CONTACT_ANGLE
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
#include <mpi.h>
|
||||
|
||||
#include "pmmc.h"
|
||||
#include "Domain.h"
|
||||
@@ -14,6 +13,7 @@
|
||||
#include "D3Q7.h"
|
||||
#include "Color.h"
|
||||
#include "Communication.h"
|
||||
#include "common/MPI.h"
|
||||
|
||||
//#define CBUB
|
||||
//#define WRITE_SURFACES
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
#include <mpi.h>
|
||||
|
||||
#include "Communication.h"
|
||||
#include "common/MPI.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
</FilePatterns>
|
||||
<CXXFLAGS>
|
||||
-I${LBPM_INSTALL_DIR}/include
|
||||
-DUSE_MPI
|
||||
-I${MPI_INCLUDE}
|
||||
${MPI_CXXFLAGS}
|
||||
${TIMER_CXXFLAGS}
|
||||
</CXXFLAGS>
|
||||
<LDFLAGS>
|
||||
|
||||
Reference in New Issue
Block a user