Skip to content
Snippets Groups Projects
Commit 19350d67 authored by 数学の武士's avatar 数学の武士
Browse files

Add alloc

parent f081ee87
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,9 @@
namespace memproc
{
template <MemType memtype>
bool realloc(void *&array, const size_t new_size);
template <MemType memtype>
bool realloc(void *&array, size_t &allocated_size, const size_t new_size);
......
......@@ -4,6 +4,9 @@
namespace memproc
{
template <MemType memtype>
bool alloc(void *&array, const size_t new_size);
template <MemType memtype>
bool realloc(void *&array, size_t &allocated_size, const size_t new_size);
......
......@@ -21,6 +21,16 @@ bool memproc::dealloc<MemType::CPU>(void *&array)
return true;
}
template <>
bool memproc::alloc<MemType::CPU>(void *&array, const size_t new_size)
{
array = malloc(new_size);
memset(array, 0, new_size);
return true;
}
template <>
bool memproc::realloc<MemType::CPU>(void *&array, size_t &allocated_size, const size_t new_size)
{
......
......@@ -21,6 +21,15 @@ bool memproc::dealloc<MemType::GPU>(void *&array)
return true;
}
template <>
bool memproc::alloc<MemType::GPU>(void *&array, const size_t new_size)
{
cudaMalloc ( (void **)&array, new_size);
cudaMemset(array, 0, new_size);
return true;
}
template <>
bool memproc::realloc<MemType::GPU>(void *&array, size_t &allocated_size, const size_t new_size)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment