59 entryOnMultipleProcs_(false),
63 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
66 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
86 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
96 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
106 throw "Epetra_BasicDirectory::Epetra_BasicDirectory: Unknown map index type";
115 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
121 throw "Epetra_BasicDirectory::Epetra_BasicDirectory: ERROR, GlobalIndicesInt but no API for it.";
124 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
128 Generate<long long>(Map);
130 throw "Epetra_BasicDirectory::Epetra_BasicDirectory: ERROR, GlobalIndicesLongLong but no API for it.";
145 entryOnMultipleProcs_(false),
148 SizeIsConst_(Directory.SizeIsConst_)
149 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
152 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
172 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
179 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
193 for(
int i=0; i<num; ++i) {
200 for(
int j=0; j<len; ++j) {
228 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
232 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
259 int insertPoint = -1;
271 template<
typename int_type>
280 int_type Dir_NumGlobalElements = MaxAllGID - MinAllGID + 1;
291 if (Dir_NumMyElements>0) {
292 ProcList_ =
new int[ Dir_NumMyElements ];
298 for (i=0; i<Dir_NumMyElements; i++) {
311 int * send_procs = 0;
312 if (Map_NumMyElements>0) send_procs =
new int[Map_NumMyElements];
313 int_type * Map_MyGlobalElements = 0;
314 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
318 Map_MyGlobalElements,
322 bool det_flag =
true;
330 if (Map_NumMyElements>0)
delete [] send_procs;
332 int * export_elements = 0;
333 char * c_import_elements = 0;
334 int * import_elements = 0;
335 int len_import_elements = 0;
336 int * ElementSizeList = 0;
338 int packetSize = (int) (
sizeof(int_type) + 2*
sizeof(int))/
sizeof(int);
341 if (Map_NumMyElements>0) {
343 export_elements =
new int[ packetSize * Map_NumMyElements ];
344 int * ptr = export_elements;
345 for( i = 0; i < Map_NumMyElements; i++ )
347 *(int_type*)ptr = Map_MyGlobalElements[i];
348 ptr +=
sizeof(int_type)/
sizeof(
int);
359 packetSize * (
int)
sizeof(
int ),
361 c_import_elements ));
363 import_elements =
reinterpret_cast<int *
>(c_import_elements);
368 int * ptr = import_elements;
369 for( i = 0; i < num_recvs; i++ )
372 ptr +=
sizeof(int_type)/
sizeof(
int);
374 assert(curr_LID !=-1);
396 int localval, globalval;
401 if (len_import_elements!=0)
delete [] c_import_elements;
402 if (export_elements!=0)
delete [] export_elements;
418 template<
typename int_type>
420 const int NumEntries,
421 const int_type * GlobalEntries,
425 bool high_rank_sharing_procs)
const
440 int * ElementSizeList = 0;
442 if (ConstantElementSize)
446 for (i=0; i<NumEntries; i++) {
447 int LID = Map.
LID(GlobalEntries[i]);
453 else Procs[i] = MyPID;
456 if (LocalEntries!=0) LocalEntries[i] = LID;
460 if (ConstantElementSize)
461 EntrySizes[i] = ElementSize;
463 EntrySizes[i] = ElementSizeList[LID];
477 for (i=0; i<NumEntries; i++) {
480 int_type GID = GlobalEntries[i];
481 if (GID<MinAllGID) ierr = 1;
482 else if (GID>MaxAllGID) ierr = 1;
487 const int_type* AllMinGIDs_ptr = AllMinGIDs<int_type>();
489 while (Proc1 >= 0 && Proc1< NumProc) {
490 if (AllMinGIDs_ptr[Proc1]<=GID) {
491 if (GID <AllMinGIDs_ptr[Proc1+1]) {
501 LID = (int) (GID - AllMinGIDs_ptr[Proc]);
505 if (LocalEntries!=0) LocalEntries[i] = LID;
510 for (i=0; i<NumEntries; i++) EntrySizes[i] = ElementSize;
519 int_type * Size_send_gids = 0;
520 int * Size_send_procs = 0;
524 Size_num_sends, Size_send_gids, Size_send_procs ));
526 int * Size_exports = 0;
527 char * c_Size_imports = 0;
528 int * Size_imports = 0;
529 int packetSize = (int) (
sizeof(int_type) +
sizeof(int))/
sizeof(int);
530 if (Size_num_sends>0) {
531 Size_exports =
new int[ packetSize * Size_num_sends ];
532 for( i = 0; i < Size_num_sends; i++ )
534 int_type Size_curr_GID = Size_send_gids[i];
535 int Size_curr_LID = Map.
LID(Size_curr_GID);
536 assert(Size_curr_LID!=-1);
537 *(int_type*)(Size_exports + packetSize*i) = Size_curr_GID;
538 int Size_curr_size = ElementSizeList[Size_curr_LID];
539 *(Size_exports + packetSize*i + (packetSize - 1)) = Size_curr_size;
543 int len_Size_imports = 0;
545 packetSize * (
int)
sizeof(
int ),
548 Size_imports =
reinterpret_cast<int*
>(c_Size_imports);
550 for( i = 0; i < NumEntries; i++ )
555 int_type Size_curr_GID = *(int_type*)(Size_imports + packetSize*i);
556 for( j = 0; j < NumEntries; j++ )
557 if( Size_curr_GID == GlobalEntries[j] )
559 EntrySizes[j] = *(Size_imports + packetSize*i + (packetSize - 1));
567 if( Size_send_gids != 0 )
delete [] Size_send_gids;
568 if( Size_send_procs != 0 )
delete [] Size_send_procs;
570 if( len_Size_imports != 0 )
delete [] c_Size_imports;
571 if( Size_exports != 0 )
delete [] Size_exports;
582 int PacketSize = (int) (
sizeof(int_type) +
sizeof(int))/
sizeof(int);
583 bool DoSizes =
false;
587 for (i=0; i<NumEntries; i++) EntrySizes[i] = ElementSize;
595 bool DoLIDs = (LocalEntries!=0);
596 if (DoLIDs) PacketSize++;
603 if (NumEntries>0) dir_procs =
new int[ NumEntries ];
605 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
612 {
for( i = 0; i < NumEntries; ++i )
613 if( dir_procs[i] == -1 )
616 if (DoLIDs) LocalEntries[i] = -1;
621 int_type * send_gids = 0;
622 int * send_procs = 0;
625 num_sends, send_gids, send_procs));
627 if (NumEntries>0)
delete [] dir_procs;
632 char * c_imports = 0;
636 exports =
new int[ PacketSize * num_sends ];
638 for( i = 0; i < num_sends; i++ )
640 int_type curr_GID = send_gids[i];
641 *(int_type*)ptr = curr_GID;
642 ptr +=
sizeof(int_type)/
sizeof(
int);
644 assert(curr_LID!=-1);
645 if (high_rank_sharing_procs==
false) {
667 if (DoSizes) *ptr++ =
SizeList_[curr_LID];
671 int NumRecv = NumEntries - NumMissing;
673 PacketSize * (
int)
sizeof(
int ),
676 imports =
reinterpret_cast<int*
>(c_imports);
681 int* sortedGE_int =
new int[NumEntries*(1 +
sizeof(int_type)/
sizeof(
int))];
682 int* offsets = sortedGE_int+NumEntries*
sizeof(int_type)/
sizeof(
int);
683 int_type* sortedGE =
reinterpret_cast<int_type*
>(sortedGE_int);
685 for(i=0; i<NumEntries; ++i) {
689 std::memcpy(sortedGE, GlobalEntries, NumEntries*
sizeof(int_type));
691 Utils.
Sort(
true, NumEntries, sortedGE, 0, 0, 1, &offsets, 0, 0);
696 for( i = 0; i < NumRecv; i++ ) {
697 int_type theCurrentLID = *(int_type*)ptr;
698 ptr +=
sizeof(int_type)/
sizeof(
int);
701 Procs[offsets[j]] = *ptr++;
702 if (DoLIDs) LocalEntries[offsets[j]] = *ptr++;
703 if (DoSizes) EntrySizes[offsets[j]] = *ptr++;
707 delete [] sortedGE_int;
709 if( send_gids )
delete [] send_gids;
710 if( send_procs )
delete [] send_procs;
712 if( len_imports )
delete [] c_imports;
713 if( exports )
delete [] exports;
720 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
722 const int NumEntries,
723 const int * GlobalEntries,
727 bool high_rank_sharing_procs)
const
730 throw "Epetra_BasicDirectory::GetDirectoryEntries: int version can't be called for non int map";
732 return GetDirectoryEntries<int>(Map, NumEntries, GlobalEntries, Procs,
733 LocalEntries, EntrySizes, high_rank_sharing_procs);
737 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
742 const int NumEntries,
743 const long long * GlobalEntries,
747 bool high_rank_sharing_procs)
const
750 throw "Epetra_BasicDirectory::GetDirectoryEntries: long long version can't be called for non long long map";
752 return GetDirectoryEntries<long long>(Map, NumEntries, GlobalEntries, Procs,
753 LocalEntries, EntrySizes, high_rank_sharing_procs);
763 os << MyPID <<
" Epetra_BasicDirectory Object: "
766 os <<
" " << i <<
" " <<
ProcList_[i] <<
" "
776 std::cout <<
"Epetra_BasicDirectory not setup<<<<<<" << std::endl;
787 bool throw_error =
true;
789 std::cerr << std::endl
790 <<
"Epetra_BasicDirectory::operator= not supported."
long long MinMyGID64() const
long long MaxAllGID64() const
Epetra_Map: A class for partitioning vectors and matrices.
bool DistributedGlobal() const
Returns true if map is defined across more than one processor.
const Epetra_Map & DirectoryMap() const
Returns the Epetra_Map containing the directory.
bool entryOnMultipleProcs_
bool GlobalIndicesLongLong() const
Returns true if map create with long long NumGlobalElements.
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
virtual int GatherAll(double *MyVals, double *AllVals, int Count) const =0
Epetra_Comm All Gather function.
bool GIDsAllUniquelyOwned() const
GIDsAllUniquelyOwned: returns true if all GIDs appear on just one processor.
Epetra_BasicDirectory(const Epetra_BlockMap &Map)
Epetra_BasicDirectory constructor.
long long NumGlobalElements64() const
int GetDirectoryEntries(const Epetra_BlockMap &Map, const int NumEntries, const int *GlobalEntries, int *Procs, int *LocalEntries, int *EntrySizes, bool high_rank_sharing_procs=false) const
GetDirectoryEntries : Returns proc and local id info for non-local map entries.
virtual int CreateFromSends(const int &NumExportIDs, const int *ExportPIDs, bool Deterministic, int &NumRemoteIDs)=0
Create Distributor object using list of process IDs to which we export.
bool ConstantElementSize() const
Returns true if map has constant element size.
virtual ~Epetra_BasicDirectory(void)
Epetra_BasicDirectory destructor.
#define EPETRA_CHK_ERR(a)
int * ElementSizeList() const
List of the element sizes corresponding to the array MyGlobalElements().
bool GlobalIndicesInt() const
Returns true if map create with int NumGlobalElements.
virtual int MyPID() const =0
Return my process ID.
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
Epetra_Util: The Epetra Util Wrapper Class.
int NumMyElements() const
Number of elements on the calling processor.
int Generate(const Epetra_BlockMap &Map)
Generate: Sets up Directory tables.
long long MinAllGID64() const
void create_ProcListArrays()
Epetra_BasicDirectory: This class allows Epetra_Map objects to reference non-local elements...
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int MyGlobalElementsPtr(int *&MyGlobalElementList) const
long long * AllMinGIDs_LL_
int LID(int GID) const
Returns local ID of global ID, return -1 if not found on this processor.
int Epetra_Util_binary_search(T item, const T *list, int len, int &insertPoint)
Utility function to perform a binary-search on a list of data.
Epetra_BasicDirectory & operator=(const Epetra_BasicDirectory &src)
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
virtual int Do(char *export_objs, int obj_size, int &len_import_objs, char *&import_objs)=0
Execute plan on buffer of export objects in a single step.
bool LinearMap() const
Returns true if the global ID space is contiguously divided (but not necessarily uniformly) across al...
virtual int CreateFromRecvs(const int &NumRemoteIDs, const int *RemoteGIDs, const int *RemotePIDs, bool Deterministic, int &NumExportIDs, int *&ExportGIDs, int *&ExportPIDs)=0
Create Distributor object using list of Remote global IDs and corresponding PIDs. ...
virtual int NumProc() const =0
Returns total number of processes.
Epetra_Map * DirectoryMap_
virtual Epetra_Distributor * CreateDistributor() const =0
Create a distributor object.
virtual void Print(std::ostream &os) const
Print method.
int MaxElementSize() const
Maximum element size across all processors.
void addProcToList(int proc, int LID)
static void Sort(bool SortAscending, int NumKeys, T *Keys, int NumDoubleCompanions, double **DoubleCompanions, int NumIntCompanions, int **IntCompanions, int NumLongLongCompanions, long long **LongLongCompanions)
Epetra_Util Sort Routine (Shell sort)
int Epetra_Util_insert(T item, int offset, T *&list, int &usedLength, int &allocatedLength, int allocChunkSize=32)
Function to insert an item in a list, at a specified offset.
int RemoteIDList(int NumIDs, const int *GIDList, int *PIDList, int *LIDList) const
Returns the processor IDs and corresponding local index value for a given list of global indices...