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 21 hsa_status_t Runtime::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 DEBUG_PRINT("Malloced %p\n", *ptr); 25 26 if (err == HSA_STATUS_SUCCESS) { 27 err = core::allow_access_to_all_gpu_agents(*ptr); 28 } 29 return (err == HSA_STATUS_SUCCESS) ? HSA_STATUS_SUCCESS : HSA_STATUS_ERROR; 30 } 31 32 hsa_status_t Runtime::Memfree(void *ptr) { 33 hsa_status_t err = hsa_amd_memory_pool_free(ptr); 34 DEBUG_PRINT("Freed %p\n", ptr); 35 36 return (err == HSA_STATUS_SUCCESS) ? HSA_STATUS_SUCCESS : HSA_STATUS_ERROR; 37 } 38 39 } // namespace core 40