1 //===--- amdgpu/impl/interop_hsa.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 "interop_hsa.h"
9 #include "internal.h"
10
interop_hsa_get_symbol_info(const std::map<std::string,atl_symbol_info_t> & SymbolInfoTable,int DeviceId,const char * symbol,void ** var_addr,unsigned int * var_size)11 hsa_status_t interop_hsa_get_symbol_info(
12 const std::map<std::string, atl_symbol_info_t> &SymbolInfoTable,
13 int DeviceId, const char *symbol, void **var_addr, unsigned int *var_size) {
14 /*
15 // Typical usage:
16 void *var_addr;
17 size_t var_size;
18 interop_hsa_get_symbol_addr(gpu_place, "symbol_name", &var_addr,
19 &var_size);
20 impl_memcpy(signal, host_add, var_addr, var_size);
21 */
22
23 if (!symbol || !var_addr || !var_size)
24 return HSA_STATUS_ERROR;
25
26 // get the symbol info
27 std::string symbolStr = std::string(symbol);
28 auto It = SymbolInfoTable.find(symbolStr);
29 if (It != SymbolInfoTable.end()) {
30 atl_symbol_info_t info = It->second;
31 *var_addr = reinterpret_cast<void *>(info.addr);
32 *var_size = info.size;
33 return HSA_STATUS_SUCCESS;
34 } else {
35 *var_addr = NULL;
36 *var_size = 0;
37 return HSA_STATUS_ERROR;
38 }
39 }
40