Commit 22b0ed11 authored by incardon's avatar incardon

Added Ata work

parent 37d8d518
Pipeline #1283 failed with stages
in 17 seconds
/*
* ShmAllocator_manager.cpp
*
* Created on: Aug 13, 2019
* Author: i-bird
*/
#include "ShmAllocator_manager.hpp"
ShmAllocator_manager * shm_man_sing = NULL;
ShmAllocator_manager & create_shmanager()
{
if (shm_man_sing == NULL)
{
shm_man_sing = new ShmAllocator_manager();
}
return *shm_man_sing;
}
void destroy_shmanager()
{
if (shm_man_sing != NULL)
{
delete(shm_man_sing);
}
}
/*
* ShmAllocator_manager.hpp
*
* Created on: Aug 13, 2019
* Author: i-bird
*/
#ifndef SHMALLOCATOR_MANAGER_HPP_
#define SHMALLOCATOR_MANAGER_HPP_
#include <vector>
#include "ShmAllocator.hpp"
struct handle_shmem
{
int id;
};
class ShmAllocator_manager
{
std::vector<ShmAllocator *> mems;
public:
~ShmAllocator_manager()
{
for (int i = 0 ; i < mems.size() ; i++)
{
handle_shmem hs;
hs.id = i;
destroy(hs);
}
}
/*! \brief Allocate new shared memory
*
* \param name shared memory name
* \param rank processor rank
*
*/
handle_shmem create(const std::string & name, int rank)
{
mems.push_back(NULL);
mems[mems.size()-1] = new ShmAllocator(name,rank);
handle_shmem hs;
hs.id = mems.size()-1;
return hs;
}
/*! \brief Allocate shared memory
*
* \param Allocator handle
* \param size of the memory to allocate
*
*/
void * alloc(handle_shmem handle, size_t size)
{
return mems[handle.id]->shm_alloc(size);
}
/*! \brief Free shared memory
*
* \param handle
* \param ptr pointer to the shared memory
*
*/
void free(handle_shmem handle, void * ptr)
{
mems[handle.id]->shm_free(ptr);
}
/*! \brief Destroy shared allocator
*
* \param handle
*
*/
void destroy(handle_shmem handle)
{
delete(mems[handle.id]);
}
};
ShmAllocator_manager & create_shmanager();
void destroy_shmanager();
#endif /* SHMALLOCATOR_MANAGER_HPP_ */
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