Commit 14682857 authored by incardon's avatar incardon

Adding refactorization for Ata work

parent 88943949
......@@ -8,7 +8,7 @@ else()
set(CUDA_SOURCES )
endif()
add_executable(mem_map ../../openfpm_devices/src/Memleak_check.cpp main.cpp util/multi_array_openfpm/multi_array_ref_openfpm_unit_test.cpp memory_ly/memory_conf_unit_tests.cpp Space/tests/SpaceBox_unit_tests.cpp Grid/copy_grid_unit_test.cpp NN/Mem_type/Mem_type_unit_tests.cpp ${CUDA_SOURCES} ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp)
add_executable(mem_map ../../openfpm_devices/src/Memleak_check.cpp main.cpp util/multi_array_openfpm/multi_array_ref_openfpm_unit_test.cpp memory_ly/memory_conf_unit_tests.cpp Space/tests/SpaceBox_unit_tests.cpp Grid/copy_grid_unit_test.cpp NN/Mem_type/Mem_type_unit_tests.cpp ${CUDA_SOURCES} ../../openfpm_devices/src/memory/ShmAllocator_manager.cpp ../../openfpm_devices/src/memory/SemManager.cpp ../../openfpm_devices/src/memory/ShmAllocator.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp)
if ( CMAKE_COMPILER_IS_GNUCC )
target_compile_options(mem_map PRIVATE "-Wno-deprecated-declarations")
......
......@@ -122,12 +122,15 @@ struct mem_get<p,layout,data_type,g1_type,key_type,1>
template<typename layout, typename data_type, bool is_empty, unsigned int sel = 2*is_layout_mlin<layout>::value + is_layout_inte<layout>::value>
struct mem_shmem
{
__host__ static inline void set_shmem_key(data_type & data_,key_t key)
__host__ static inline void set_shmem_handle(data_type & data_,handle_shmem sh)
{}
__host__ static inline key_t get_shmem_key(data_type & data_)
__host__ static inline handle_shmem get_shmem_handle(data_type & data_)
{
return -1;
handle_shmem sh;
sh.id = -1;
return sh;
}
};
......@@ -135,14 +138,14 @@ struct mem_shmem
template<typename layout, typename data_type>
struct mem_shmem<layout,data_type,false,2>
{
__host__ static inline void set_shmem_key(data_type & data_,key_t key)
__host__ static inline void set_shmem_handle(data_type & data_,handle_shmem sh)
{
data_.mem->set_shmem_key(key);
data_.mem->set_shmem_handle(sh);
}
__host__ static inline key_t get_shmem_key(data_type & data_)
__host__ static inline handle_shmem get_shmem_handle(data_type & data_)
{
return data_.mem->get_shmem_key();
return data_.mem->get_shmem_handle();
}
};
......@@ -150,16 +153,16 @@ struct mem_shmem<layout,data_type,false,2>
template<typename S, typename layout, typename data_type, typename g1_type, unsigned int sel = 2*is_layout_mlin<layout>::value + is_layout_inte<layout>::value >
struct mem_setm
{
static inline void init_shmem(data_type & data_,const char * name, int proj_id)
static inline void init_shmem(data_type & data_,handle_shmem shid)
{
data_.set_memory_name(name,proj_id);
data_.init_shmem(shid);
}
static inline void setMemory(data_type & data_, const g1_type & g1, bool & is_mem_init, key_t key)
static inline void setMemory(data_type & data_, const g1_type & g1, bool & is_mem_init, handle_shmem shid)
{
S * mem = new S();
mem->set_shmem_key(key);
mem->set_shmem_handle(shid);
//! Create and set the memory allocator
data_.setMemory(*mem);
......@@ -175,12 +178,12 @@ struct mem_setm
template<typename S, typename layout, typename data_type, typename g1_type>
struct mem_setm<S,layout,data_type,g1_type,1>
{
static inline void init_shmem(data_type & data_,const char * name, int proj_id)
static inline void init_shmem(data_type & data_,handle_shmem shid)
{
// TODO implement shared memory implementation
}
static inline void setMemory(data_type & data_, const g1_type & g1, bool & is_mem_init, key_t key)
static inline void setMemory(data_type & data_, const g1_type & g1, bool & is_mem_init, handle_shmem sh)
{
//! Create an allocate object
allocate<S> all(g1.size());
......
......@@ -233,8 +233,8 @@ private:
//! The memory allocator is not internally created
bool isExternal;
// shared_memory key
key_t key = -1;
// shared_memory handle
handle_shmem sh_handle;
#ifdef SE_CLASS1
......@@ -433,7 +433,7 @@ private:
while(it.isNext())
{
// get the grid key
// get the grid sh_handle
grid_key_dx<dim> key = it.get();
// create a copy element
......@@ -477,6 +477,7 @@ public:
grid_base_impl() THROW
:g1(0),isExternal(false)
{
sh_handle.id = -1;
// Add this pointer
#ifdef SE_CLASS2
check_new(this,8,GRID_EVENT,1);
......@@ -492,6 +493,7 @@ public:
grid_base_impl(const grid_base_impl & g) THROW
:isExternal(false)
{
sh_handle.id = -1;
this->operator=(g);
}
......@@ -503,6 +505,7 @@ public:
grid_base_impl(const size_t & sz) THROW
:g1(sz),isExternal(false)
{
sh_handle.id = -1;
// Add this pointer
#ifdef SE_CLASS2
check_new(this,8,GRID_EVENT,1);
......@@ -519,6 +522,7 @@ public:
grid_base_impl(const size_t (& sz)[dim]) THROW
:g1(sz),isExternal(false)
{
sh_handle.id = -1;
// Add this pointer
#ifdef SE_CLASS2
check_new(this,8,GRID_EVENT,1);
......@@ -686,7 +690,7 @@ public:
check_valid(this,8);
#endif
mem_setm<S,layout_base<T>,decltype(this->data_),decltype(this->g1)>::setMemory(data_,g1,is_mem_init,key);
mem_setm<S,layout_base<T>,decltype(this->data_),decltype(this->g1)>::setMemory(data_,g1,is_mem_init,sh_handle);
}
/*! \brief Get the object that provide memory
......@@ -992,7 +996,7 @@ public:
grid_base_impl<dim,T,S,layout,layout_base> grid_new(sz);
grid_new.set_shmem_key(this->get_shmem_key());
grid_new.set_shmem_handle(this->get_shmem_handle());
resize_impl_memset(grid_new);
......@@ -1327,14 +1331,14 @@ public:
return grid_key_dx_iterator_sub<dim>(g1,m);
}
inline key_t get_shmem_key()
inline handle_shmem get_shmem_handle()
{
return mem_shmem<layout_base<T>,decltype(this->data_),boost::mpl::size<typename T::type>::type::value == 0>::get_shmem_key(data_);
return mem_shmem<layout_base<T>,decltype(this->data_),boost::mpl::size<typename T::type>::type::value == 0>::get_shmem_handle(data_);
}
inline void set_shmem_key(key_t k)
inline void set_shmem_handle(handle_shmem sh)
{
this->key = k;
this->sh_handle = sh;
}
/*! \brief Return a grid iterator
......@@ -1455,9 +1459,9 @@ public:
* \
*
*/
void init_shmem(const char * pathname, int proj_id)
void init_shmem(handle_shmem shid)
{
mem_setm<S,layout_base<T>,decltype(this->data_),decltype(this->g1)>::init_shmem(data_,pathname,proj_id);
mem_setm<S,layout_base<T>,decltype(this->data_),decltype(this->g1)>::init_shmem(data_,shid);
}
};
......
......@@ -1828,9 +1828,9 @@ namespace openfpm
* \
*
*/
void init_shmem(const char * pathname, int proj_id)
void init_shmem(handle_shmem shid)
{
base.init_shmem(pathname,proj_id);
base.init_shmem(shid);
}
void * internal_get_size_pointer() {return &v_size;}
......
......@@ -204,11 +204,11 @@ class memory_c<T,MEMORY_C_STANDARD,D>
mem_obj.mem_r.swap(mem_r);
}
void set_memory_name(const char * pathname, int proj_id)
void init_shmem(handle_shmem shid)
{
mem->set_memory_name(pathname,proj_id);
mem->set_shmem_handle(shid);
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment