Add support for the hipFuncGetAttributes interface.

이 커밋은 다음에 포함됨:
Alex Voicu
2018-05-11 03:35:10 +01:00
부모 e8dd9297ae
커밋 bf9529aaa8
6개의 변경된 파일189개의 추가작업 그리고 20개의 파일을 삭제
+24
파일 보기
@@ -94,6 +94,19 @@ typedef struct ihipModule_t* hipModule_t;
typedef struct ihipModuleSymbol_t* hipFunction_t;
struct hipFuncAttributes {
int binaryVersion;
int cacheModeCA;
size_t constSizeBytes;
size_t localSizeBytes;
int maxDynamicSharedSizeBytes;
int maxThreadsPerBlock;
int numRegs;
int preferredShmemCarveout;
int ptxVersion;
size_t sharedSizeBytes;
};
typedef struct ihipEvent_t* hipEvent_t;
enum hipLimit_t {
@@ -2222,6 +2235,17 @@ hipError_t hipModuleUnload(hipModule_t module);
*/
hipError_t hipModuleGetFunction(hipFunction_t* function, hipModule_t module, const char* kname);
/**
* @bried Find out attributes for a given function.
*
* @param [out] attr
* @param [in] func
*
* @returns hipSuccess, hipErrorInvalidDeviceFunction
*/
hipError_t hipFuncGetAttributes(hipFuncAttributes* attr, const void* func);
/**
* @brief returns device memory pointer and size of the kernel present in the module with symbol @p
* name
+41 -5
파일 보기
@@ -22,8 +22,10 @@ THE SOFTWARE.
#pragma once
#include <hsa/amd_hsa_kernel_code.h>
#include <hsa/hsa.h>
#include <hsa/hsa_ext_amd.h>
#include <hsa/hsa_ven_amd_loader.h>
#include <cstddef>
#include <istream>
@@ -46,11 +48,45 @@ struct hash<hsa_agent_t> {
inline constexpr bool operator==(hsa_agent_t x, hsa_agent_t y) { return x.handle == y.handle; }
namespace hip_impl {
struct Kernel_descriptor {
std::uint64_t kernel_object_;
std::uint32_t group_size_;
std::uint32_t private_size_;
std::string name_;
class Kernel_descriptor {
std::uint64_t kernel_object_{};
amd_kernel_code_t const* kernel_header_{nullptr};
std::string name_{};
public:
Kernel_descriptor() = default;
Kernel_descriptor(std::uint64_t kernel_object, const std::string& name)
: kernel_object_{kernel_object}, name_{name}
{
bool supported{false};
std::uint16_t min_v{UINT16_MAX};
auto r = hsa_system_major_extension_supported(
HSA_EXTENSION_AMD_LOADER, 1, &min_v, &supported);
if (r != HSA_STATUS_SUCCESS || !supported) return;
hsa_ven_amd_loader_1_01_pfn_t tbl{};
r = hsa_system_get_major_extension_table(
HSA_EXTENSION_AMD_LOADER,
1,
sizeof(tbl),
reinterpret_cast<void*>(&tbl));
if (r != HSA_STATUS_SUCCESS) return;
if (!tbl.hsa_ven_amd_loader_query_host_address) return;
r = tbl.hsa_ven_amd_loader_query_host_address(
reinterpret_cast<void*>(kernel_object_),
reinterpret_cast<const void**>(&kernel_header_));
if (r != HSA_STATUS_SUCCESS) return;
}
Kernel_descriptor(const Kernel_descriptor&) = default;
Kernel_descriptor(Kernel_descriptor&&) = default;
~Kernel_descriptor() = default;
Kernel_descriptor& operator=(const Kernel_descriptor&) = default;
Kernel_descriptor& operator=(Kernel_descriptor&&) = default;
operator hipFunction_t() const { // TODO: this is awful and only meant for illustration.
return reinterpret_cast<hipFunction_t>(const_cast<Kernel_descriptor*>(this));