From 5affc25237be36d6186544b64f6cb73dfa2cb260 Mon Sep 17 00:00:00 2001 From: "e.vaca.cerda" Date: Thu, 1 Sep 2022 21:24:01 +0200 Subject: [PATCH] shared memory type --- python/shared_memory.hpp | 10 ++++++---- src/meepgeom.cpp | 15 +++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/python/shared_memory.hpp b/python/shared_memory.hpp index 5aa7cf546..413fb3c06 100644 --- a/python/shared_memory.hpp +++ b/python/shared_memory.hpp @@ -42,7 +42,6 @@ int *model; int i, flag; int windisp; - int *winptr; MPI_Aint winsize; MPI_Win winarray; @@ -50,7 +49,7 @@ 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); @@ -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; @@ -81,7 +83,7 @@ if (node_rank == 0) { memcpy(dest, src, count); - std::cout << "copying the values from process ["< 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); } diff --git a/src/meepgeom.cpp b/src/meepgeom.cpp index 6b83d109b..281d58081 100644 --- a/src/meepgeom.cpp +++ b/src/meepgeom.cpp @@ -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; @@ -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; }