Commit 86377f47 authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

preparations for pack/unpack with large data; recover streamlines in DrawGrid

parent ac1cc6af
...@@ -132,9 +132,9 @@ namespace INMOST ...@@ -132,9 +132,9 @@ namespace INMOST
return; return;
} }
printf("preparing octree around mesh, was sets %d\n", mesh->NumberOfSets()); printf("preparing octree around mesh, was sets %d\n", mesh->NumberOfSets());
SearchKDTree octsearch(mesh); //~ SearchKDTree octsearch(mesh);
//~ Octree octsearch = Octree(mesh->CreateSet("octsearch").first); Octree octsearch = Octree(mesh->CreateSet("octsearch").first);
//~ octsearch.Construct(vel_def, false); //auto-detect octree or quadtree octsearch.Construct(vel_def, false); //auto-detect octree or quadtree
printf("done, sets %d\n", mesh->NumberOfSets()); printf("done, sets %d\n", mesh->NumberOfSets());
printf("building streamlines\n"); printf("building streamlines\n");
Tag cell_size = mesh->CreateTag("STREAMLINES_TEMPORARY_CELL_SIZES", DATA_REAL, CELL, NONE, 1); Tag cell_size = mesh->CreateTag("STREAMLINES_TEMPORARY_CELL_SIZES", DATA_REAL, CELL, NONE, 1);
...@@ -259,13 +259,13 @@ namespace INMOST ...@@ -259,13 +259,13 @@ namespace INMOST
mesh->DeleteTag(cell_size); mesh->DeleteTag(cell_size);
printf("done, total streamlines = %lu\n", output.size()); printf("done, total streamlines = %lu\n", output.size());
printf("killing octree, was sets %d\n", mesh->NumberOfSets()); printf("killing octree, was sets %d\n", mesh->NumberOfSets());
//~ octsearch.Destroy(); octsearch.Destroy();
printf("done, sets %d\n", mesh->NumberOfSets()); printf("done, sets %d\n", mesh->NumberOfSets());
} }
Streamline::Streamline(SearchKDTree & octsearch, coord pos, Tag velocity_tag, ElementType velocity_defined, Tag cell_size, Storage::real velocity_min, Storage::real velocity_max, Storage::real sign, MarkerType visited) Streamline::Streamline(const Octree & octsearch, coord pos, Tag velocity_tag, ElementType velocity_defined, Tag cell_size, Storage::real velocity_min, Storage::real velocity_max, Storage::real sign, MarkerType visited)
{ {
Storage::real coef, len, size; Storage::real coef, len, size;
coord next = pos, vel; coord next = pos, vel;
...@@ -277,8 +277,8 @@ namespace INMOST ...@@ -277,8 +277,8 @@ namespace INMOST
velarr.push_back(0); velarr.push_back(0);
while (points.size() < maxsteps) while (points.size() < maxsteps)
{ {
//c = octsearch.FindClosestCell(next.data()); c = octsearch.FindClosestCell(next.data());
c = octsearch.SearchCell(next.data()); //~ c = octsearch.SearchCell(next.data());
if (!c.isValid()) break; if (!c.isValid()) break;
//if( !c.getAsCell().Inside(next.data()) ) break; //if( !c.getAsCell().Inside(next.data()) ) break;
//check we are inside mesh //check we are inside mesh
......
...@@ -17,7 +17,7 @@ namespace INMOST ...@@ -17,7 +17,7 @@ namespace INMOST
std::vector<double> velarr; std::vector<double> velarr;
public: public:
Streamline() {} Streamline() {}
Streamline(SearchKDTree & octsearch, coord pos, Tag velocity_tag, ElementType velocity_defined, Tag cell_size, Storage::real velocity_min, Storage::real velocity_max, Storage::real sign, MarkerType visited); Streamline(const Octree & octsearch, coord pos, Tag velocity_tag, ElementType velocity_defined, Tag cell_size, Storage::real velocity_min, Storage::real velocity_max, Storage::real sign, MarkerType visited);
Streamline(const Streamline & other) { points = other.points; velarr = other.velarr; } Streamline(const Streamline & other) { points = other.points; velarr = other.velarr; }
Streamline & operator =(Streamline const & other) { points = other.points; velarr = other.velarr; return *this; } Streamline & operator =(Streamline const & other) { points = other.points; velarr = other.velarr; return *this; }
~Streamline() { points.clear(); velarr.clear(); } ~Streamline() { points.clear(); velarr.clear(); }
......
...@@ -64,22 +64,106 @@ static std::string NameSlash(std::string input) ...@@ -64,22 +64,106 @@ static std::string NameSlash(std::string input)
#define PROCESSID -1 #define PROCESSID -1
#endif #endif
#if 1
#define MPI_Pack_call(data,size,type,buf,buf_size,pos,comm) MPI_Pack(data,size,type,buf,buf_size,pos,comm)
#define MPI_Pack_size_call(size,type,comm,ret) MPI_Pack_size(size,type,comm,ret)
#define MPI_Unpack_call(buf,buf_size,pos,data,size,type,comm) MPI_Unpack(buf,buf_size,pos,data,size,type,comm)
#define POS_TYPE int
#define SEND_AS MPI_PACKED
#else
#define MPI_Pack_call(data,size,type,buf,buf_size,pos,comm) MPI_Pack_external("external32",data,size,type,buf,buf_size,pos)
#define MPI_Pack_size_call(size,type,comm,ret) MPI_Pack_external_size("external32",size,type,ret)
#define MPI_Unpack_call(buf,buf_size,pos,data,size,type,comm) MPI_Unpack_external("external32",buf,buf_size,pos,data,size,type)
#define POS_TYPE MPI_Aint
#define SEND_AS MPI_BYTE
#endif
#if SIZE_MAX == UCHAR_MAX
#define MPI_SIZE_T MPI_UNSIGNED_CHAR
#elif SIZE_MAX == USHRT_MAX
#define MPI_SIZE_T MPI_UNSIGNED_SHORT
#elif SIZE_MAX == UINT_MAX
#define MPI_SIZE_T MPI_UNSIGNED
#elif SIZE_MAX == ULONG_MAX
#define MPI_SIZE_T MPI_UNSIGNED_LONG
#elif SIZE_MAX == ULLONG_MAX
#define MPI_SIZE_T MPI_UNSIGNED_LONG_LONG
#else
#error "Cannot detect size_t type"
#endif
namespace INMOST namespace INMOST
{ {
//static int block_recursion = 0;
/* template<typename T> struct MPIType;
std::string ro() template<> struct MPIType<bool> {static MPI_Datatype Type() {return MPI_C_BOOL;}};
{ template<> struct MPIType<char> {static MPI_Datatype Type() {return MPI_CHAR;}};
int rank = 0; template<> struct MPIType<int> {static MPI_Datatype Type() {return MPI_INT;}};
#ifdef USE_MPI template<> struct MPIType<short> {static MPI_Datatype Type() {return MPI_SHORT;}};
MPI_Comm_rank(MPI_COMM_WORLD,&rank); template<> struct MPIType<long> {static MPI_Datatype Type() {return MPI_LONG;}};
#endif template<> struct MPIType<long long> {static MPI_Datatype Type() {return MPI_LONG_LONG;}};
std::stringstream ss; template<> struct MPIType<unsigned char> {static MPI_Datatype Type() {return MPI_UNSIGNED_CHAR;}};
for (int i = 0; i < rank; i++) template<> struct MPIType<unsigned short> {static MPI_Datatype Type() {return MPI_UNSIGNED_SHORT;}};
ss << " "; template<> struct MPIType<unsigned> {static MPI_Datatype Type() {return MPI_UNSIGNED;}};
return ss.str(); template<> struct MPIType<unsigned long> {static MPI_Datatype Type() {return MPI_UNSIGNED_LONG;}};
} template<> struct MPIType<unsigned long long> {static MPI_Datatype Type() {return MPI_UNSIGNED_LONG_LONG;}};
*/ template<> struct MPIType<double> {static MPI_Datatype Type() {return MPI_DOUBLE;}};
template<> struct MPIType<long double> {static MPI_Datatype Type() {return MPI_LONG_DOUBLE;}};
template<> struct MPIType<float> {static MPI_Datatype Type() {return MPI_FLOAT;}};
//template<> struct MPIType<size_t> {static MPI_Datatype Type() {return MPI_SIZE_T;}};
template<typename T>
void pack_data(Mesh::exch_buffer_type & buf, const T & data, INMOST_MPI_Comm comm)
{
int ierr;
POS_TYPE pack_size = 0, shift;
size_t write_pos = buf.size();
MPI_Pack_size_call(1,MPIType<T>::Type(),comm,&pack_size);
buf.resize(write_pos+pack_size);
MPI_Pack_call((void*)&data,1,MPIType<T>::Type(),&buf[write_pos],pack_size,&shift,comm);
buf.resize(write_pos+shift);
}
template<typename T>
void pack_data_array(Mesh::exch_buffer_type & buf, const std::vector<T> & data, INMOST_MPI_Comm comm)
{
pack_data(buf,data.size(),comm);
if( !data.empty() )
{
POS_TYPE pack_size = 0, shift;
size_t write_pos = buf.size();
MPI_Pack_size_call((int)data.size(),MPIType<T>::Type(),comm,&pack_size);
buf.resize(write_pos+pack_size);
MPI_Pack_call((void *)&data[0],data.size(),MPIType<T>::Type(),&buf[write_pos],pack_size,&shift,comm);
buf.resize(write_pos+shift);
}
}
template<typename T>
void unpack_data(Mesh::exch_buffer_type & buf, int & pos, T & data, INMOST_MPI_Comm comm)
{
POS_TYPE lpos = (POS_TYPE)pos;
MPI_Unpack_call((void*)&buf[0],(int)buf.size(),&lpos,&data,1,MPIType<T>::Type(),comm);
pos = (int)lpos;
}
template<typename T>
void unpack_data_array(Mesh::exch_buffer_type & buf, int & pos, std::vector<T> & data, INMOST_MPI_Comm comm)
{
size_t unpack_size;
unpack_data(buf,pos,unpack_size,comm);
data.resize(unpack_size);
POS_TYPE lpos = (POS_TYPE)pos;
MPI_Unpack_call((void*)&buf[0],(int)buf.size(),&lpos,&data[0],(int)unpack_size,MPIType<T>::Type(),comm);
pos = (int)lpos;
}
////////////////////////////// //////////////////////////////
/// REDUCTION FUNCTIONS /// /// REDUCTION FUNCTIONS ///
////////////////////////////// //////////////////////////////
......
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