Skip to content

Commit

Permalink
fix: use MY_MPI_UWORD to gether sizes
Browse files Browse the repository at this point in the history
It is unsigned long when  ARMA_32BIT_WORD is defined; otherwise, unsigned long long.
  • Loading branch information
HPDell committed Jul 14, 2024
1 parent ed8db53 commit 6ebc89c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions include/gwmodelpp/utils/armampi.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#include "armadillo_config.h"
#include "mpi.h"

#ifdef ARMA_32BIT_WORD
#define MY_MPI_UWORD MPI_UNSIGNED_LONG
#else // ARMA_32BIT_WORD
#define MY_MPI_UWORD MPI_UNSIGNED_LONG_LONG
#endif // ARMA_32BIT_WORD

void mat_mul_mpi(arma::mat& a, arma::mat& b, arma::mat& c, const int ip, const int np, const size_t range);
3 changes: 2 additions & 1 deletion src/gwmodelpp/GWRBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#ifdef ENABLE_MPI
#include "mpi.h"
#include "gwmodelpp/utils/armampi.h"
#endif

using namespace std;
Expand Down Expand Up @@ -78,7 +79,7 @@ mat GWRBasic::fit()
aShape[3] = mWorkRangeSize;
// cout << mWorkerId << " process send size: [" << aShape[0] << "," << aShape[1] << "," << aShape[2] << "," << aShape[3] << "]\n";
}
MPI_Bcast(aShape, 4, MPI_UNSIGNED_LONG_LONG, 0, MPI_COMM_WORLD);
MPI_Bcast(aShape, 4, MY_MPI_UWORD, 0, MPI_COMM_WORLD);
if (mWorkerId > 0) // slave process
{
// cout << mWorkerId << " process recv size: [" << aShape[0] << "," << aShape[1] << "," << aShape[2] << "," << aShape[3] << "]\n";
Expand Down
6 changes: 3 additions & 3 deletions src/gwmodelpp/GWRMultiscale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ mat GWRMultiscale::fit()
aShape[2] = nDim;
aShape[3] = mWorkRangeSize;
}
MPI_Bcast(aShape, 4, MPI_UNSIGNED_LONG_LONG, 0, MPI_COMM_WORLD);
MPI_Bcast(aShape, 4, MY_MPI_UWORD, 0, MPI_COMM_WORLD);
if (mWorkerId > 0) // slave process
{
nDp = aShape[0];
Expand Down Expand Up @@ -975,7 +975,7 @@ double GWRMultiscale::bandwidthSizeCriterionVarCVMpi(BandwidthWeight* bandwidthW
{
status = 0;
}
MPI_Allgather(&status, 1, MPI_UNSIGNED_LONG_LONG, status_all.memptr(), 1, MPI_UNSIGNED_LONG_LONG, MPI_COMM_WORLD);
MPI_Allgather(&status, 1, MY_MPI_UWORD, status_all.memptr(), 1, MY_MPI_UWORD, MPI_COMM_WORLD);
if (!all(status_all))
return DBL_MAX;

Expand Down Expand Up @@ -1015,7 +1015,7 @@ double GWRMultiscale::bandwidthSizeCriterionVarAICMpi(BandwidthWeight* bandwidth
{
status = 0;
}
MPI_Allgather(&status, 1, MPI_UNSIGNED_LONG_LONG, status_all.memptr(), 1, MPI_UNSIGNED_LONG_LONG, MPI_COMM_WORLD);
MPI_Allgather(&status, 1, MY_MPI_UWORD, status_all.memptr(), 1, MY_MPI_UWORD, MPI_COMM_WORLD);
if (!all(status_all))
return DBL_MAX;

Expand Down

0 comments on commit 6ebc89c

Please sign in to comment.