42 #include "utils/logger.h"
61 unsigned int blockLength[],
unsigned long displacements[],
Type types[])
63 return new grid::Grid(count, blockLength, displacements, types);
83 int mpiResult; NDBG_UNUSED(mpiResult);
85 typedef char procName_t[MPI_MAX_PROCESSOR_NAME+1];
91 MPI_Get_processor_name(procName, &procNameLength);
92 assert(procNameLength <= MPI_MAX_PROCESSOR_NAME);
94 procName[procNameLength] =
'\0';
97 const uint8_t* buffer =
reinterpret_cast<const uint8_t*
>(procName);
101 for (
int i = 0; i < procNameLength; i++) {
102 s1 = (s1 + buffer[i]) % 65521;
103 s2 = (s2 + s1) % 65521;
106 uint32_t hash = (s2 << 16) | s1;
108 mpiResult = MPI_Comm_rank(comm, &rank);
109 assert(mpiResult == MPI_SUCCESS);
112 mpiResult = MPI_Comm_split(comm, hash, rank, &nodeComm);
113 assert(mpiResult == MPI_SUCCESS);
117 mpiResult = MPI_Comm_size(nodeComm, &nodeSize);
118 assert(mpiResult == MPI_SUCCESS);
120 procName_t* procNames =
new procName_t[nodeSize];
122 mpiResult = MPI_Allgather(procName, MPI_MAX_PROCESSOR_NAME+1, MPI_CHAR,
123 procNames, MPI_MAX_PROCESSOR_NAME+1, MPI_CHAR, nodeComm);
124 assert(mpiResult == MPI_SUCCESS);
128 int nodeRank, realNodeRank = 0;
129 mpiResult = MPI_Comm_rank(nodeComm, &nodeRank);
130 assert(mpiResult == MPI_SUCCESS);
132 for (
int i = 0; i < nodeRank; i++) {
133 if (strcmp(procName, procNames[i]) == 0)
138 mpiResult = MPI_Comm_free(&nodeComm);
139 assert(mpiResult == MPI_SUCCESS);
146 #endif // ASAGI_NOMPI
163 unsigned int blockLength[],
164 unsigned long displacements[],
175 #endif // ASAIG_NOMPI
183 const char* value,
unsigned int level)
185 handle->
setParam(name, value, level);
191 return handle->
open(filename, level);
224 return handle->
getByte(pos, level);
229 return handle->
getInt(pos, level);
234 return handle->
getLong(pos, level);
239 return handle->
getFloat(pos, level);
249 handle->
getBuf(buf, pos, level);
274 #endif // ASAGI_NOMPI
static void stopCommThread()
virtual double getDouble(const double *pos, unsigned int level=0)=0
subroutine asagi_stop_comm_thread()
static CommThread commThread
integer(kind=c_int) function asagi_grid_dimensions(grid_id)
real(kind=c_double) function asagi_grid_max(grid_id, n)
asagi::Grid::Error init(int schedCPU, MPI_Comm comm=MPI_COMM_WORLD)
static asagi::Grid * createStruct(unsigned int count, unsigned int blockLength[], unsigned long displacements[], Type types[])
virtual unsigned int getVarSize() const =0
subroutine asagi_grid_set_comm(grid_id, comm)
integer(kind=c_int) function asagi_grid_create_struct(count, block_length, displacments, types)
integer function asagi_grid_create_array(basictype)
integer function asagi_grid_open(grid_id, filename, level)
subroutine asagi_grid_set_param(grid_id, name, value, level)
integer(kind=c_int) function asagi_grid_var_size(grid_id)
subroutine asagi_grid_close(grid_id)
static Error startCommThread(int schedCPU=-1, MPI_Comm comm=MPI_COMM_WORLD)
virtual unsigned char getByte(const double *pos, unsigned int level=0)=0
virtual void setParam(const char *name, const char *value, unsigned int level=0)=0
Changes a grid parameter.
subroutine asagi_grid_set_threads(grid_id, threads)
virtual long getLong(const double *pos, unsigned int level=0)=0
static asagi::Grid * createArray(Type type=FLOAT)
Include file for C and C++ API.
C++ Interface for ASAGI grids.
virtual Error open(const char *filename, unsigned int level=0)=0
Loads values from a NetCDF file.
static asagi::Grid * create(Type type=FLOAT)
virtual Error setThreads(unsigned int threads)=0
Sets the number of threads in the application.
virtual int getInt(const double *pos, unsigned int level=0)=0
virtual void getBuf(void *buf, const double *pos, unsigned int level=0)=0
virtual float getFloat(const double *pos, unsigned int level=0)=0
virtual double getMax(unsigned int n) const =0
integer(kind=c_int) function asagi_start_comm_thread(sched_cpu, comm)
real function asagi_grid_get_float(grid_id, pos, level)
virtual Error setComm(MPI_Comm comm=MPI_COMM_WORLD)=0
subroutine asagi_grid_get_buf(grid_id, buf, pos, level)
integer(kind=c_int) function asagi_node_local_rank(comm)
real(kind=c_double) function asagi_grid_delta(grid_id, n, level)
virtual unsigned int getDimensions() const =0
Returns the number of dimensions loaded from the file.
virtual double getMin(unsigned int n) const =0
virtual double getDelta(unsigned int n, unsigned int level=0) const =0
integer function asagi_grid_create(type)
static int nodeLocalRank(MPI_Comm comm=MPI_COMM_WORLD)
real(kind=c_double) function asagi_grid_get_double(grid_id, pos, level)
real(kind=c_double) function asagi_grid_min(grid_id, n)
character function asagi_grid_get_byte(grid_id, pos, level)
integer(kind=c_long) function asagi_grid_get_long(grid_id, pos, level)
integer function asagi_grid_get_int(grid_id, pos, level)