From 9609e9526719efcdc96ee8cd20ba8bd3f5d66d4f Mon Sep 17 00:00:00 2001
From: foreman
Date: Tue, 24 May 2016 15:00:34 -0500
Subject: [PATCH] P4 to Git Change 1272517 by gandryey@gera-w8 on 2016/05/24
15:54:08
SWDEV-94524 - [OCL] Call to clBuildProgram crashes amdocl64.dll
- Detect offline device and return a fake srd handle. Compiler must reload binary for a specific device in order for the binary to have proper functionality
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#226 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#5 edit
[ROCm/clr commit: 4c47086ac44d547a0a2a2ce38fe3d5d892ba9a38]
---
projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp | 10 +++++++++-
projects/clr/rocclr/runtime/device/pal/palprogram.cpp | 8 +++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp
index 2073b339a8..84153ea6a0 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp
@@ -2461,13 +2461,21 @@ void* ORCAHSALoaderContext::SegmentAddress(amdgpu_hsa_elf_segment_t segment,
hsa_status_t ORCAHSALoaderContext::SamplerCreate(
hsa_agent_t agent,
const hsa_ext_sampler_descriptor_t *sampler_descriptor,
- hsa_ext_sampler_t *sampler_handle) {
+ hsa_ext_sampler_t *sampler_handle)
+{
if (!agent.handle) {
return HSA_STATUS_ERROR_INVALID_AGENT;
}
if (!sampler_descriptor || !sampler_handle) {
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
+
+ if (program_->isNull()) {
+ // Offline compilation. Provide a fake handle to avoid an assert
+ sampler_handle->handle = 1;
+ return HSA_STATUS_SUCCESS;
+ }
+
uint32_t state = 0;
switch (sampler_descriptor->coordinate_mode) {
case HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED: state = amd::Sampler::StateNormalizedCoordsFalse; break;
diff --git a/projects/clr/rocclr/runtime/device/pal/palprogram.cpp b/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
index 1535faf103..cc0fabd828 100644
--- a/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
@@ -811,13 +811,19 @@ void* ORCAHSALoaderContext::SegmentAddress(amdgpu_hsa_elf_segment_t segment,
hsa_status_t ORCAHSALoaderContext::SamplerCreate(
hsa_agent_t agent,
const hsa_ext_sampler_descriptor_t *sampler_descriptor,
- hsa_ext_sampler_t *sampler_handle) {
+ hsa_ext_sampler_t *sampler_handle)
+{
if (!agent.handle) {
return HSA_STATUS_ERROR_INVALID_AGENT;
}
if (!sampler_descriptor || !sampler_handle) {
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
+ if (program_->isNull()) {
+ // Offline compilation. Provide a fake handle to avoid an assert
+ sampler_handle->handle = 1;
+ return HSA_STATUS_SUCCESS;
+ }
uint32_t state = 0;
switch (sampler_descriptor->coordinate_mode) {
case HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED: state = amd::Sampler::StateNormalizedCoordsFalse; break;