Commit feb29c2c authored by Shen Yu's avatar Shen Yu
Browse files

modified: Makefile

	new file:   bin/.bin
	renamed:    GlobalComm.h -> include/GlobalComm.h
	renamed:    ../openmpi-4.1.1/ompi/mpi/c/_MSGLOG_.h -> include/_MSGLOG_.h
	new file:   include/commset.h
	renamed:    createMPIComm.h -> include/createMPIComm.h
	renamed:    read_run.h -> include/read_run.h
	new file:   lib/.lib
	renamed:    GlobalComm.cpp -> src/GlobalComm.cpp
	renamed:    commset.h -> src/commset.c
	renamed:    createMPIComm.cpp -> src/createMPIComm.cpp
	renamed:    mpi_player.cpp -> src/mpi_player.cpp
	renamed:    read_run.cpp -> src/read_run.cpp

    setup new directories
parent 7390e792
OPT = -std=c++11 -D_DEBUG
OPT = -D_DEBUG
INC = -Iinclude
MPICXX = mpicxx
MPICC = mpicc
mpi_player: createMPIComm.o read_run.o mpi_player.o
mpicxx -o mpi_player createMPIComm.o read_run.o mpi_player.o $(OPT)
all: bin/mpi_player lib/GlobalComm.a
createMPIComm.o: createMPIComm.cpp
mpicxx -c createMPIComm.cpp $(OPT)
bin/mpi_player: createMPIComm.o read_run.o mpi_player.o
[ -e bin ] || mkdir bin; $(MPICXX) -o bin/mpi_player createMPIComm.o read_run.o mpi_player.o $(OPT)
read_run.o: read_run.cpp
mpicxx -c read_run.cpp $(OPT)
lib/GlobalComm.a: GlobalComm.o commset.o
[ -e lib ] || mkdir lib; ar rcsv lib/GlobalComm.a GlobalComm.o commset.o
mpi_player.o: mpi_player.cpp
mpicxx -c mpi_player.cpp $(OPT)
createMPIComm.o: src/createMPIComm.cpp
$(MPICXX) -c src/createMPIComm.cpp $(OPT) $(INC)
read_run.o: src/read_run.cpp
$(MPICXX) -c src/read_run.cpp $(OPT) $(INC)
mpi_player.o: src/mpi_player.cpp
$(MPICXX) -c src/mpi_player.cpp $(OPT) $(INC)
GlobalComm.o: src/GlobalComm.cpp
$(MPICXX) -c src/GlobalComm.cpp $(OPT) $(INC)
commset.o: src/commset.c
$(MPICC) -c src/commset.c $(OPT) $(INC)
clean:
rm mpi_player *.o 2>/dev/null
rm bin/mpi_player lib/GlobalComm.a *.o 2>/dev/null
......@@ -3,13 +3,7 @@
#define __MSGLOG_H__
#include <stdio.h>
#include <sys/time.h>
struct CommSet
{
int n; // number of comms in the set
int maxsize; // set maxsize
MPI_Comm* comms; // the array containing the comms
};
#include "commset.h"
extern struct CommSet localComm;
......@@ -118,7 +112,7 @@ inline int init_REQ_POOL(int size)
{
if(size > REQ_POOL_SIZE)
{
int* new_pool=realloc(REQ_POOL, size*sizeof(int));
int* new_pool=(int*)realloc(REQ_POOL, size*sizeof(int));
if(new_pool)
{
REQ_POOL=new_pool;
......@@ -139,67 +133,5 @@ inline void free_REQ_POOL()
REQ_POOL_SIZE=0;
}
inline int initCommSet(struct CommSet *CS)
{
CS->n=0;
CS->maxsize=16;
CS->comms=(MPI_Comm*)malloc(sizeof(MPI_Comm)*CS->maxsize);
if(CS->comms == NULL)
return -1;
else
return 0;
}
inline bool inCommSet(MPI_Comm comm, struct CommSet *CS)
{
bool r=false;
for(int i=0; i<CS->n; ++i)
{
if(CS->comms[i] == comm)
{
r=true;
break;
}
}
return r;
}
inline int addComm(MPI_Comm comm, struct CommSet *CS)
{
if(inCommSet(comm, CS))
return 0;
if(CS->n < CS->maxsize)
{
CS->comms[CS->n]=comm;
++(CS->n);
}
else
{
int oldmaxsize=CS->maxsize;
MPI_Comm* oldSet=CS->comms;
CS->maxsize *= 2;
CS->comms=(MPI_Comm*)malloc(sizeof(MPI_Comm)*CS->maxsize);
if(CS->comms == NULL)
{
CS->comms=oldSet;
return -1;
}
else
{
for(int i=0; i<oldmaxsize; ++i)
CS->comms[i]=oldSet[i];
free(oldSet);
CS->comms[CS->n]=comm;
++(CS->n);
}
}
return 0;
}
inline void freeCommSet(struct CommSet *CS)
{
free(CS->comms);
CS->comms=NULL;
}
#endif
// end
struct CommSet
{
int n; // number of comms in the set
int maxsize; // set maxsize
MPI_Comm* comms; // the array containing the comms
};
inline int initCommSet(struct CommSet *CS);
inline int inCommSet(MPI_Comm comm, struct CommSet *CS);
inline int addComm(MPI_Comm comm, struct CommSet *CS);
inline void freeCommSet(struct CommSet *CS);
......@@ -5,7 +5,10 @@
#include <map>
#include <fstream>
#include <mpi.h>
#include "commset.hpp"
extern "C"
{
#include "_MSGLOG_.h"
}
using namespace std;
// every process build it communicator member list
......
struct CommSet
{
int n; // number of comms in the set
int maxsize; // set maxsize
MPI_Comm* comms; // the array containing the comms
};
#include <stdlib.h>
#include <mpi.h>
#include <commset.h>
inline int initCommSet(struct CommSet *CS)
{
......@@ -16,14 +14,14 @@ inline int initCommSet(struct CommSet *CS)
return 0;
}
inline bool inCommSet(MPI_Comm comm, struct CommSet *CS)
inline int inCommSet(MPI_Comm comm, struct CommSet *CS)
{
bool r=false;
int r=0;
for(int i=0; i<CS->n; ++i)
{
if(CS->comms[i] == comm)
{
r=true;
r=1;
break;
}
}
......@@ -32,7 +30,7 @@ inline bool inCommSet(MPI_Comm comm, struct CommSet *CS)
inline int addComm(MPI_Comm comm, struct CommSet *CS)
{
if(inCommSet(comm, CS))
if(inCommSet(comm, CS) == 1)
return 0;
if(CS->n < CS->maxsize)
{
......@@ -66,4 +64,4 @@ inline void freeCommSet(struct CommSet *CS)
{
free(CS->comms);
CS->comms=NULL;
}
\ No newline at end of file
}
Markdown is supported
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