Commit 19697c29 authored by Tristan Webb's avatar Tristan Webb

Add create gpu buffer helper function

parent 59ec0797
......@@ -553,7 +553,8 @@ void runtime::gpu::GPU_ExternalFunction::compile()
size_t temp_pool_size = current_function->get_temporary_pool_size();
writer << "// Allocate the memory pool\n";
// TODO memory pool malloc.
writer << "void** pool_base_ptr;\n";
writer << "void** pool_base_ptr = runtime::gpu::create_gpu_buffer(" << temp_pool_size
<< ");\n";
// Add temporaries to the variable name map
for (shared_ptr<Node> node : current_function->get_ordered_ops())
......
......@@ -45,6 +45,13 @@ void runtime::gpu::check_cuda_errors(CUresult err)
assert(err == CUDA_SUCCESS);
}
void** runtime::gpu::create_gpu_buffer(size_t buffer_size)
{
void** allocated_buffer_pool;
cudaMalloc(&allocated_buffer_pool, buffer_size);
return allocated_buffer_pool;
}
void runtime::gpu::cuda_memcpyDtD(void* d, void* s, size_t element_count, size_t element_size)
{
size_t size_in_bytes = element_size * element_count;
......
......@@ -22,6 +22,7 @@ namespace ngraph
{
void print_gpu_f32_tensor(void* p, size_t element_count, size_t element_size);
void check_cuda_errors(CUresult err);
void** create_gpu_buffer(size_t buffer_size);
void cuda_memcpyDtD(void* d, void* s, size_t element_count, size_t element_size);
void cuda_memcpyHtD(void* d, void* s, size_t buffer_size);
}
......
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