Skip to content

Commit

Permalink
shared memory type
Browse files Browse the repository at this point in the history
  • Loading branch information
e.vaca.cerda committed Sep 1, 2022
1 parent c9c9c9d commit 5affc25
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 6 additions & 4 deletions python/shared_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@
int *model;
int i, flag;
int windisp;
int *winptr;
MPI_Aint winsize;
MPI_Win winarray;

// Only rank 0 on a node actually allocates memory
localarraysize = 0;
if (node_rank == 0) localarraysize = arraysize;

MPI_Win_allocate_shared(localarraysize*sizeof(int), sizeof(int),
MPI_Win_allocate_shared(localarraysize*sizeof(T), sizeof(T),
MPI_INFO_NULL, nodecomm, &localarray, &winarray);

MPI_Win_get_attr(winarray, MPI_WIN_MODEL, &model, &flag);
Expand All @@ -64,6 +63,9 @@
MPI_Win_shared_query(winarray, 0, &winsize, &windisp, &array);
}

printf("POINTER TO SHARED ARRAY IN PROCESS %d: = %p, SHARED= %p\n", world_rank , (void *) &array, (void *) array);


MPI_Win_fence(0, winarray);

return array;
Expand All @@ -81,7 +83,7 @@

if (node_rank == 0) {
memcpy(dest, src, count);
std::cout << "copying the values from process ["<<node_rank << "/" <<node_size<<"] \n" ;
std::cout << "copying the values in the shared memory ["<<node_rank << "/" <<node_size<<"] \n" ;
}
MPI_Barrier(MPI_COMM_WORLD);
}
Expand All @@ -95,7 +97,7 @@

template<class T>
void memcpy_shared(T* dest, const T* src, size_t count ) {
std::cout << "copying the values from all processes \n" ;
std::cout << "copying the values on every process \n" ;
memcpy(dest, src, count);
}

Expand Down
15 changes: 11 additions & 4 deletions src/meepgeom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void material_gc(material_type m) {
m->medium_2.H_susceptibilities.clear();
}


void material_free(material_type m) {
if (!m) return;

Expand All @@ -119,11 +120,17 @@ void material_free(material_type m) {

// NOTE: We do not delete the user_data field here since it is an opaque/void
// object so will assume that the caller keeps track of its lifetime.
delete[] m->epsilon_data;
m->epsilon_data = NULL;

//MPI_Win_free(&md->epsilon_adress);
//MPI_Win_free(&md->weights_adress);

// delete[] m->epsilon_data;
//m->epsilon_data = NULL;
//delete[] m->epsilon_adress;

delete[] m->weights;
m->weights = NULL;
// delete[] m->weights;
//m->weights = NULL;
//delete[] m->weights_adress;
delete m;
}

Expand Down

0 comments on commit 5affc25

Please sign in to comment.