Skip to content

Commit

Permalink
Fix template specialization issue in DInfo class.
Browse files Browse the repository at this point in the history
  • Loading branch information
oehmke committed Oct 4, 2023
1 parent a93c27d commit 8901328
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Infrastructure/Mesh/include/ESMCI_DInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,19 @@ class DInfo {

// Set of templated calls to support different id types in allreduce
template<class IDTYPE>
static void _get_global_minmax(IDTYPE lmin, IDTYPE lmax, IDTYPE &t_gmin, IDTYPE &t_gmax) {
void DINFO_get_global_minmax(IDTYPE lmin, IDTYPE lmax, IDTYPE &t_gmin, IDTYPE &t_gmax) {
Throw() << "Unsupported id type.";
}

template<>
static void _get_global_minmax(int lmin, int lmax, int &t_gmin, int &t_gmax) {
void DINFO_get_global_minmax(int lmin, int lmax, int &t_gmin, int &t_gmax) {
MPI_Allreduce(&lmin, &t_gmin, 1, MPI_INT, MPI_MIN, Par::Comm());
MPI_Allreduce(&lmax, &t_gmax, 1, MPI_INT, MPI_MAX, Par::Comm());
}

// Set of templated call to calculate proc from id and global info
template<class IDTYPE>
static UInt _calc_proc_from_id(IDTYPE id, UInt petCount, IDTYPE gmin, IDTYPE gmax) {
UInt DINFO_calc_proc_from_id(IDTYPE id, UInt petCount, IDTYPE gmin, IDTYPE gmax) {
//std::cout << "id ="<<id<<" petCount="<<petCount<<" gmin="<<gmin<<" gmax="<<gmax<<std::endl;

UInt num_per_proc = ((gmax-gmin+1) + petCount -1) / petCount;
Expand Down Expand Up @@ -193,15 +193,15 @@ void DInfo<IDTYPE, INFOTYPE> :: commit() {
}

// Get global min and max id
_get_global_minmax(lmin, lmax, gmin, gmax);
DINFO_get_global_minmax(lmin, lmax, gmin, gmax);

// Loop ids, set up sends
std::vector<UInt> to_proc; // procs I will send to
std::vector<UInt> send_sizes_all(petCount, 0);
for (auto i = 0; i < staging.size(); i++) {

// Figure out which proc this id would be on
UInt tproc = _calc_proc_from_id(staging[i].id, petCount, gmin, gmax);
UInt tproc = DINFO_calc_proc_from_id(staging[i].id, petCount, gmin, gmax);

// Add to send list
to_proc.push_back(tproc);
Expand Down Expand Up @@ -231,7 +231,7 @@ void DInfo<IDTYPE, INFOTYPE> :: commit() {
for (auto i = 0; i < staging.size(); i++) {

// Figure out which proc this id would be on
UInt tproc = _calc_proc_from_id(staging[i].id, petCount, gmin, gmax);
UInt tproc = DINFO_calc_proc_from_id(staging[i].id, petCount, gmin, gmax);

// Get buffer for tproc
SparseMsg::buffer &b = *msg.getSendBuffer(tproc);
Expand Down Expand Up @@ -371,7 +371,7 @@ void DInfo<IDTYPE, INFOTYPE> :: search(int num_search,
for (auto i = 0; i < num_search; i++) {

// Figure out which proc this id would be on
UInt proc = _calc_proc_from_id(search_ids[i], petCount, gmin, gmax);
UInt proc = DINFO_calc_proc_from_id(search_ids[i], petCount, gmin, gmax);

// Add proc to list
to_proc.push_back(proc);
Expand Down Expand Up @@ -399,7 +399,7 @@ void DInfo<IDTYPE, INFOTYPE> :: search(int num_search,
for (auto i = 0; i < num_search; i++) {

// Figure out which proc this id would be on
UInt proc = _calc_proc_from_id(search_ids[i], petCount, gmin, gmax);
UInt proc = DINFO_calc_proc_from_id(search_ids[i], petCount, gmin, gmax);

// Get buffer going to that proc
SparseMsg::buffer &b = *msg.getSendBuffer(proc);
Expand Down Expand Up @@ -540,7 +540,7 @@ void DInfo<IDTYPE, INFOTYPE> :: search(int num_search,
for (UInt i = 0; i < num_search; i++) {

// Figure out which proc this search id would be on
UInt proc = _calc_proc_from_id(search_ids[i], petCount, gmin, gmax);
UInt proc = DINFO_calc_proc_from_id(search_ids[i], petCount, gmin, gmax);

// Get buffer for this proc
SparseMsg::buffer &b = *msg.getRecvBuffer(proc);
Expand Down

0 comments on commit 8901328

Please sign in to comment.