@@ -2088,7 +2088,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
2088
2088
// / Allocate and construct an AMDGPU kernel.
2089
2089
Expected<GenericKernelTy &> constructKernel (const char *Name) override {
2090
2090
// Allocate and construct the AMDGPU kernel.
2091
- AMDGPUKernelTy *AMDGPUKernel = Plugin ::get ().allocate <AMDGPUKernelTy>();
2091
+ AMDGPUKernelTy *AMDGPUKernel = PluginTy ::get ().allocate <AMDGPUKernelTy>();
2092
2092
if (!AMDGPUKernel)
2093
2093
return Plugin::error (" Failed to allocate memory for AMDGPU kernel" );
2094
2094
@@ -2139,7 +2139,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
2139
2139
int32_t ImageId) override {
2140
2140
// Allocate and initialize the image object.
2141
2141
AMDGPUDeviceImageTy *AMDImage =
2142
- Plugin ::get ().allocate <AMDGPUDeviceImageTy>();
2142
+ PluginTy ::get ().allocate <AMDGPUDeviceImageTy>();
2143
2143
new (AMDImage) AMDGPUDeviceImageTy (ImageId, *this , TgtImage);
2144
2144
2145
2145
// Load the HSA executable.
@@ -2697,7 +2697,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
2697
2697
}
2698
2698
Error setDeviceHeapSize (uint64_t Value) override {
2699
2699
for (DeviceImageTy *Image : LoadedImages)
2700
- if (auto Err = setupDeviceMemoryPool (Plugin ::get (), *Image, Value))
2700
+ if (auto Err = setupDeviceMemoryPool (PluginTy ::get (), *Image, Value))
2701
2701
return Err;
2702
2702
DeviceMemoryPoolSize = Value;
2703
2703
return Plugin::success ();
@@ -2737,7 +2737,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
2737
2737
return utils::iterateAgentMemoryPools (
2738
2738
Agent, [&](hsa_amd_memory_pool_t HSAMemoryPool) {
2739
2739
AMDGPUMemoryPoolTy *MemoryPool =
2740
- Plugin ::get ().allocate <AMDGPUMemoryPoolTy>();
2740
+ PluginTy ::get ().allocate <AMDGPUMemoryPoolTy>();
2741
2741
new (MemoryPool) AMDGPUMemoryPoolTy (HSAMemoryPool);
2742
2742
AllMemoryPools.push_back (MemoryPool);
2743
2743
return HSA_STATUS_SUCCESS;
@@ -3115,6 +3115,17 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
3115
3115
return Plugin::check (Status, " Error in hsa_shut_down: %s" );
3116
3116
}
3117
3117
3118
+ // / Creates an AMDGPU device.
3119
+ GenericDeviceTy *createDevice (int32_t DeviceId, int32_t NumDevices) override {
3120
+ return new AMDGPUDeviceTy (DeviceId, NumDevices, getHostDevice (),
3121
+ getKernelAgent (DeviceId));
3122
+ }
3123
+
3124
+ // / Creates an AMDGPU global handler.
3125
+ GenericGlobalHandlerTy *createGlobalHandler () override {
3126
+ return new AMDGPUGlobalHandlerTy ();
3127
+ }
3128
+
3118
3129
Triple::ArchType getTripleArch () const override { return Triple::amdgcn; }
3119
3130
3120
3131
// / Get the ELF code for recognizing the compatible image binary.
@@ -3237,7 +3248,7 @@ Error AMDGPUKernelTy::launchImpl(GenericDeviceTy &GenericDevice,
3237
3248
// 56 bytes per allocation.
3238
3249
uint32_t AllArgsSize = KernelArgsSize + ImplicitArgsSize;
3239
3250
3240
- AMDHostDeviceTy &HostDevice = Plugin ::get<AMDGPUPluginTy>().getHostDevice ();
3251
+ AMDHostDeviceTy &HostDevice = PluginTy ::get<AMDGPUPluginTy>().getHostDevice ();
3241
3252
AMDGPUMemoryManagerTy &ArgsMemoryManager = HostDevice.getArgsMemoryManager ();
3242
3253
3243
3254
void *AllArgs = nullptr ;
@@ -3347,20 +3358,10 @@ Error AMDGPUKernelTy::printLaunchInfoDetails(GenericDeviceTy &GenericDevice,
3347
3358
return Plugin::success ();
3348
3359
}
3349
3360
3350
- GenericPluginTy *Plugin::createPlugin () { return new AMDGPUPluginTy (); }
3351
-
3352
- GenericDeviceTy *Plugin::createDevice (int32_t DeviceId, int32_t NumDevices) {
3353
- AMDGPUPluginTy &Plugin = get<AMDGPUPluginTy &>();
3354
- return new AMDGPUDeviceTy (DeviceId, NumDevices, Plugin.getHostDevice (),
3355
- Plugin.getKernelAgent (DeviceId));
3356
- }
3357
-
3358
- GenericGlobalHandlerTy *Plugin::createGlobalHandler () {
3359
- return new AMDGPUGlobalHandlerTy ();
3360
- }
3361
+ GenericPluginTy *PluginTy::createPlugin () { return new AMDGPUPluginTy (); }
3361
3362
3362
3363
template <typename ... ArgsTy>
3363
- Error Plugin::check (int32_t Code, const char *ErrFmt, ArgsTy... Args) {
3364
+ static Error Plugin::check (int32_t Code, const char *ErrFmt, ArgsTy... Args) {
3364
3365
hsa_status_t ResultCode = static_cast <hsa_status_t >(Code);
3365
3366
if (ResultCode == HSA_STATUS_SUCCESS || ResultCode == HSA_STATUS_INFO_BREAK)
3366
3367
return Error::success ();
@@ -3384,7 +3385,7 @@ void *AMDGPUMemoryManagerTy::allocate(size_t Size, void *HstPtr,
3384
3385
}
3385
3386
assert (Ptr && " Invalid pointer" );
3386
3387
3387
- auto &KernelAgents = Plugin ::get<AMDGPUPluginTy>().getKernelAgents ();
3388
+ auto &KernelAgents = PluginTy ::get<AMDGPUPluginTy>().getKernelAgents ();
3388
3389
3389
3390
// Allow all kernel agents to access the allocation.
3390
3391
if (auto Err = MemoryPool->enableAccess (Ptr, Size, KernelAgents)) {
@@ -3427,7 +3428,7 @@ void *AMDGPUDeviceTy::allocate(size_t Size, void *, TargetAllocTy Kind) {
3427
3428
}
3428
3429
3429
3430
if (Alloc) {
3430
- auto &KernelAgents = Plugin ::get<AMDGPUPluginTy>().getKernelAgents ();
3431
+ auto &KernelAgents = PluginTy ::get<AMDGPUPluginTy>().getKernelAgents ();
3431
3432
// Inherently necessary for host or shared allocations
3432
3433
// Also enabled for device memory to allow device to device memcpy
3433
3434
0 commit comments