1 //===--- amdgpu/impl/atmi_interop_hsa.h --------------------------- 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 #ifndef INCLUDE_ATMI_INTEROP_HSA_H_
9 #define INCLUDE_ATMI_INTEROP_HSA_H_
10 
11 #include "atmi_runtime.h"
12 #include "hsa_api.h"
13 #include "internal.h"
14 
15 #include <map>
16 #include <string>
17 
18 extern "C" {
19 
20 /** \defgroup interop_hsa_functions ATMI-HSA Interop
21  *  @{
22  */
23 
24 /**
25  * @brief Get the device address and size of an HSA global symbol
26  *
27  * @detail Use this function to query the device address and size of an HSA
28  * global symbol.
29  * The symbol can be set at by the compiler or by the application writer in a
30  * language-specific manner. This function is meaningful only after calling one
31  * of the @p atmi_module_register functions.
32  *
33  * @param[in] place The ATMI memory place
34  *
35  * @param[in] symbol Pointer to a non-NULL global symbol name
36  *
37  * @param[in] var_addr Pointer to a non-NULL @p void* variable that will
38  * hold the device address of the global symbol object.
39  *
40  * @param[in] var_size Pointer to a non-NULL @p uint variable that will
41  * hold the size of the global symbol object.
42  *
43  * @retval ::HSA_STATUS_SUCCESS The function has executed successfully.
44  *
45  * @retval ::HSA_STATUS_ERROR If @p symbol, @p var_addr or @p var_size are
46  * invalid
47  * location in the current node, or if ATMI is not initialized.
48  */
49 hsa_status_t atmi_interop_hsa_get_symbol_info(
50     const std::map<std::string, atl_symbol_info_t> &SymbolInfoTable,
51     int DeviceId, const char *symbol, void **var_addr, unsigned int *var_size);
52 
53 /**
54  * @brief Get the HSA-specific kernel info from a kernel name
55  *
56  * @detail Use this function to query the HSA-specific kernel info from the
57  * kernel name.
58  * This function is meaningful only after calling one
59  * of the @p atmi_module_register functions.
60  *
61  * @param[in] place The ATMI memory place
62  *
63  * @param[in] kernel_name Pointer to a char array with the kernel name
64  *
65  * @param[in] info The different possible kernel properties
66  *
67  * @param[in] value Pointer to a non-NULL @p uint variable that will
68  * hold the return value of the kernel property.
69  *
70  * @retval ::HSA_STATUS_SUCCESS The function has executed successfully.
71  *
72  * @retval ::HSA_STATUS_ERROR If @p symbol, @p var_addr or @p var_size are
73  * invalid
74  * location in the current node, or if ATMI is not initialized.
75  */
76 hsa_status_t atmi_interop_hsa_get_kernel_info(
77     const std::map<std::string, atl_kernel_info_t> &KernelInfoTable,
78     int DeviceId, const char *kernel_name, hsa_executable_symbol_info_t info,
79     uint32_t *value);
80 
81 /** @} */
82 
83 }
84 
85 #endif // INCLUDE_ATMI_INTEROP_HSA_H_
86