MPIBufferSlicer.h

Go to the documentation of this file.
00001 #ifndef MPIBUFFERSLICER_H_
00002 #define MPIBUFFERSLICER_H_
00003 
00004 #include <cstddef>
00005 #include <mpi.h>
00006 
00007 #include <iostream>
00008 
00009 using std::cerr;
00010 using std::endl;
00011 
00012 
00013 #include "globaldefinitions.h"
00014 
00015 #define MIN_MPI_SPIKE_BUFFER_SIZE 20
00016 
00017 class MPIBufferSlicer
00018 {
00019 public:
00020 
00021     typedef enum { tpOutputBuffer , tpInputBuffer } MPIBufferType;
00022 
00023     MPIBufferSlicer(MPIBufferType bufferType);
00024 
00025     void initialize(size_t analogBufferSize,
00026                     size_t maxMPIMsgSize = 0,
00027                     size_t spikeBufferSize = MPIBUFFER_BLOCK_SIZE);
00028 
00029     virtual ~MPIBufferSlicer()
00030     {}
00031     ;
00032 
00033     void reset();
00034 
00035     typedef enum { sliceAnalog, sliceMixed, sliceSpiking, sliceUndefined } SliceType;
00036 
00037     void calcNextBufferSliceDimensions();
00038 
00040     //**************************************************
00041 
00042     // Start position of the current slice of the buffer transferred.
00046     size_t currentSlicePos;
00047 
00048     // Calculated size of the analog portion of the current slice.
00050 
00053     int currentAnalogSliceSize;
00054 
00056 
00061     size_t allowedSpikeSliceSize;
00062 
00063     SliceType currentSliceType;
00064 
00065     bool thereIsMixedDataType;
00066 
00067 
00068 protected:
00069     MPIBufferType buffer_type;
00070 
00071     void *analog_buf;
00072 
00073     void *spike_buf;
00074 
00075     size_t spike_buffer_size_elements ;  // number of elements (longs or shorts, depends on the setup)
00076 
00077     size_t spike_buffer_size_bytes;   // bytes in the allocated spike buffer
00078 
00079     size_t analog_buffer_size_elements;  // this is in number of doubles
00080 
00081     size_t analog_buffer_size_bytes; // number of bytes analog buffer contains
00082 
00083     size_t max_mpi_msg_size;
00084 
00085 };
00086 
00087 #endif /*MPIBUFFERSLICER_H_*/

Generated on Wed Jul 9 16:34:37 2008 for PCSIM by  doxygen 1.5.5