Skip to content

Commit

Permalink
Define transfer type width in a single place
Browse files Browse the repository at this point in the history
  • Loading branch information
lkotipal committed Dec 2, 2024
1 parent 85abe09 commit 484438c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions spatial_cell_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,12 +773,12 @@ namespace spatial_cell {
displacements.size(),
block_lengths.data(),
displacements.data(),
MPI_UINT32_T,
transferTypeMPI,
&datatype
);
} else {
count = 0;
datatype = MPI_UINT32_T;
datatype = transferTypeMPI;
}

const bool printMpiDatatype = false;
Expand Down
7 changes: 5 additions & 2 deletions spatial_cell_cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ namespace spatial_cell {
vmesh::VelocityBlockContainer<vmesh::LocalID> blockContainer; /**< Velocity block data.*/
};

typedef uint8_t transferType;
constexpr MPI_Datatype transferTypeMPI MPI_BYTE;

class SpatialCell {
public:
SpatialCell();
Expand Down Expand Up @@ -364,7 +367,7 @@ namespace spatial_cell {
// if (sizeof(T) < 4) {
// abort_mpi("Pointer too small to cast to uint32_t!");
// }
return reinterpret_cast<const uint8_t*>(p) - reinterpret_cast<const uint8_t*>(this);
return reinterpret_cast<const transferType*>(p) - reinterpret_cast<const transferType*>(this);
}

template<typename T>
Expand All @@ -373,7 +376,7 @@ namespace spatial_cell {
// if (sizeof(T) < 4) {
// abort_mpi("Pointer too small to cast to uint32_t!");
// }
return len * sizeof(T) / sizeof(uint8_t);
return len * sizeof(T) / sizeof(transferType);
}

bool compute_block_has_content(const vmesh::GlobalID& block,const uint popID) const;
Expand Down

0 comments on commit 484438c

Please sign in to comment.