Skip to content

Commit

Permalink
fix memory leak. NOT tested as master does not compile successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
airmler committed Jan 18, 2024
1 parent 5110ad1 commit 8ffa60c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/atrip/Slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ class Slice {

static MPI_Datatype usize_dt() { return MPI_UINT64_T; }

// airmler: The following lines contain a memory leak.
// However, they are currently not used.
/*
static MPI_Datatype slice_info() {
constexpr int n = 5;
MPI_Datatype dt;
Expand All @@ -170,7 +173,7 @@ class Slice {
slice_location(),
vector(sizeof(enum Type), MPI_CHAR)
// TODO: Why this does not work on intel mpi?
/*, MPI_UINT64_T*/
//, MPI_UINT64_T //
};
static_assert(sizeof(enum Type) == 4, "Enum type not 4 bytes long");
Expand All @@ -193,14 +196,15 @@ class Slice {
MPI_Type_commit(&dt);
return dt;
}

*/
static MPI_Datatype local_database_element() {
constexpr int n = 2;
MPI_Datatype dt;
LocalDatabaseElement measure;
const std::vector<int> lengths(n, 1);
const MPI_Datatype types[n] = {vector(sizeof(enum Name), MPI_CHAR),
slice_info()};
// airmler: remove memory leaks, unused anyways
// const MPI_Datatype types[n] = {vector(sizeof(enum Name), MPI_CHAR),
// slice_info()};

// measure the displacements in the struct
size_t j = 0;
Expand All @@ -214,11 +218,11 @@ class Slice {
static_assert(sizeof(LocalDatabaseElement) == sizeof(measure),
"Measure has bad size");

MPI_Type_create_struct(n, lengths.data(), displacements, types, &dt);
MPI_Type_commit(&dt);
// MPI_Type_create_struct(n, lengths.data(), displacements, types, &dt);
// MPI_Type_commit(&dt);
return vector(sizeof(LocalDatabaseElement), MPI_CHAR);
// TODO: write tests in order to know if this works
return dt;
// return dt;
}
};
// MPI Types:1 ends here
Expand Down
1 change: 1 addition & 0 deletions src/atrip/SliceUnion.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ void SliceUnion<F>::send(size_t other_rank,
StagingBufferInfo{isend_buffer, tag, request, abc});
else free(request);
#else
MPI_Request_free(request);
free(request);
#endif /* defined(ATRIP_MPI_STAGING_BUFFERS) */
}
Expand Down

0 comments on commit 8ffa60c

Please sign in to comment.