HIP: Heterogenous-computing Interface for Portability
Loading...
Searching...
No Matches
program_state.hpp
1/*
2Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE.
21*/
22
23#pragma once
24
25#include <hsa/amd_hsa_kernel_code.h>
26#include <hsa/hsa.h>
27#include <hsa/hsa_ext_amd.h>
28#include <hsa/hsa_ven_amd_loader.h>
29
30#include <cstddef>
31#include <cstdint>
32#include <cstdlib>
33
34#include <hip/hip_common.h>
35
36struct ihipModuleSymbol_t;
37using hipFunction_t = ihipModuleSymbol_t*;
38
39namespace hip_impl {
40
41// This section contains internal APIs that
42// needs to be exported
43#ifdef __GNUC__
44#pragma GCC visibility push (default)
45#endif
46
47struct kernarg_impl;
48class kernarg {
49public:
50 kernarg();
51 kernarg(kernarg&&);
52 ~kernarg();
53 std::uint8_t* data();
54 std::size_t size();
55 void reserve(std::size_t);
56 void resize(std::size_t);
57private:
58 kernarg_impl* impl;
59};
60
62class program_state_impl;
63class program_state {
64public:
65 program_state();
66 ~program_state();
67 program_state(const program_state&) = delete;
68
69 hipFunction_t kernel_descriptor(std::uintptr_t,
70 hsa_agent_t);
71
72 kernargs_size_align get_kernargs_size_align(std::uintptr_t);
73 hsa_executable_t load_executable(const char*, const size_t,
74 hsa_executable_t,
75 hsa_agent_t);
76 hsa_executable_t load_executable_no_copy(const char*, const size_t,
77 hsa_executable_t,
78 hsa_agent_t);
79
80 void* global_addr_by_name(const char* name);
81
82private:
83 friend class agent_globals_impl;
84 program_state_impl* impl;
85};
86
88public:
89 std::size_t size(std::size_t n) const;
90 std::size_t alignment(std::size_t n) const;
91 const void* getHandle() const {return handle;};
92private:
93 const void* handle;
94 friend kernargs_size_align program_state::get_kernargs_size_align(std::uintptr_t);
95};
96
97#ifdef __GNUC__
98#pragma GCC visibility pop
99#endif
100
101inline
102__attribute__((visibility("hidden")))
103program_state& get_program_state() {
104 static program_state ps;
105 return ps;
106}
107} // Namespace hip_impl.
_Float16 __2f16 __attribute__((ext_vector_type(2)))
Definition hip_fp16_math_fwd.h:57
Definition program_state.hpp:63
Definition program_state.hpp:87