1 //===--- amdgpu/impl/data.cpp ------------------------------------- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 #include "impl_runtime.h"
9 #include "hsa_api.h"
10 #include "internal.h"
11 #include "rt.h"
12 #include <cassert>
13 #include <stdio.h>
14 #include <string.h>
15 #include <vector>
16 
17 using core::TaskImpl;
18 
19 namespace core {
20 namespace Runtime {
HostMalloc(void ** ptr,size_t size,hsa_amd_memory_pool_t MemoryPool)21 hsa_status_t HostMalloc(void **ptr, size_t size,
22                         hsa_amd_memory_pool_t MemoryPool) {
23   hsa_status_t err = hsa_amd_memory_pool_allocate(MemoryPool, size, 0, ptr);
24   DP("Malloced %p\n", *ptr);
25   if (err == HSA_STATUS_SUCCESS) {
26     err = core::allow_access_to_all_gpu_agents(*ptr);
27   }
28   return err;
29 }
30 
Memfree(void * ptr)31 hsa_status_t Memfree(void *ptr) {
32   hsa_status_t err = hsa_amd_memory_pool_free(ptr);
33   DP("Freed %p\n", ptr);
34   return err;
35 }
36 } // namespace Runtime
37 } // namespace core
38