SWDEV-303204 - Disable texture/image Apis on some devices. (#2381)

Modify texture tests to pass on devices that don't support texture.
Add hipDeviceAttributeImageSupport to check image support in runtime

Change-Id: Ia89c494e651a6198a24448b59a91e046a9ebea38
This commit is contained in:
TomSang
2021-12-02 01:16:13 -05:00
committed by GitHub
parent 0d361c5621
commit 5c8af57480
10 changed files with 77 additions and 6 deletions
+7
View File
@@ -36,6 +36,13 @@ using namespace std;
bool runTest(void);
int main(int argc, char** argv) {
int imageSupport = 0;
hipDeviceGetAttribute(&imageSupport, hipDeviceAttributeImageSupport,
p_gpuDevice);
if (!imageSupport) {
printf("Texture is not support on the device\n");
passed();
}
bool testResult=runTest();
if (testResult) {
@@ -60,6 +60,7 @@ texture<unsigned short, hipTextureType1D, hipReadModeNormalizedFloat> texus;
template<typename T>
__global__ void normalizedValTextureTest(unsigned int numElements, float* pDst)
{
#if !defined(__HIP_NO_IMAGE_SUPPORT) || !__HIP_NO_IMAGE_SUPPORT
unsigned int elementID = hipThreadIdx_x;
if(elementID >= numElements)
return;
@@ -72,6 +73,7 @@ __global__ void normalizedValTextureTest(unsigned int numElements, float* pDst)
pDst[elementID] = tex1D(texs, coord);
else if(std::is_same<T, unsigned short>::value)
pDst[elementID] = tex1D(texus, coord);
#endif
}
bool textureVerifyFilterModePoint(float *hOutputData, float *expected, size_t size) {
@@ -171,6 +173,13 @@ bool runTest() {
int main(int argc, char** argv)
{
int imageSupport = 0;
hipDeviceGetAttribute(&imageSupport, hipDeviceAttributeImageSupport,
p_gpuDevice);
if (!imageSupport) {
printf("Texture is not support on the device\n");
passed();
}
HipTest::parseStandardArguments(argc, argv, true);
int device = 0;
bool status = false;
+10 -2
View File
@@ -29,11 +29,12 @@ THE SOFTWARE.
// texture object is a kernel argument
template <typename TYPE_t>
__global__ void texture2dCopyKernel( hipTextureObject_t texObj, TYPE_t* dst,TYPE_t* A) {
#if !defined(__HIP_NO_IMAGE_SUPPORT) || !__HIP_NO_IMAGE_SUPPORT
for(int i =0;i<SIZE_H;i++)
for(int j = 0;j<SIZE_W;j++)
dst[SIZE_W*i+j] = tex2D<TYPE_t>(texObj, j, i);
__syncthreads();
#endif
}
template <typename TYPE_t>
@@ -76,7 +77,7 @@ void texture2Dtest()
texDescr.readMode = hipReadModeElementType;
hipTextureObject_t texObj;
HIPCHECK( hipCreateTextureObject(&texObj, &texRes, &texDescr, NULL));
HIPCHECK(hipCreateTextureObject(&texObj, &texRes, &texDescr, NULL));
HIPCHECK(hipMalloc((void**)&devPtrB, SIZE_W*sizeof(TYPE_t)*SIZE_H)) ;
@@ -95,6 +96,13 @@ void texture2Dtest()
int main()
{
int imageSupport = 0;
hipDeviceGetAttribute(&imageSupport, hipDeviceAttributeImageSupport,
p_gpuDevice);
if (!imageSupport) {
printf("Texture is not support on the device\n");
passed();
}
texture2Dtest<float>();
texture2Dtest<int>();
texture2Dtest<unsigned char>();
+10 -1
View File
@@ -40,10 +40,12 @@ std::vector<unsigned int> mip_vector = {8, 4, 2, 1};
__global__ void tex2DKernel(float* outputData, hipTextureObject_t textureObject, int width,
int height, float level) {
#ifndef __gfx90a__
#if !defined(__HIP_NO_IMAGE_SUPPORT) || !__HIP_NO_IMAGE_SUPPORT
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
outputData[y * width + x] = tex2DLod<float>(textureObject, x, y, level);
#endif
#endif
}
bool runMipMapTest(unsigned int width, unsigned int height, unsigned int mipmap_level) {
@@ -148,6 +150,7 @@ bool runMipMapTest(unsigned int width, unsigned int height, unsigned int mipmap_
hipDestroyTextureObject(textureObject);
hipFree(dData);
hipFreeArray(hipArray);
free(hData);
return testResult;
}
@@ -169,7 +172,13 @@ bool runTest(int argc, char** argv) {
int main(int argc, char** argv) {
bool testResult = true;
int imageSupport = 0;
hipDeviceGetAttribute(&imageSupport, hipDeviceAttributeImageSupport,
p_gpuDevice);
if (!imageSupport) {
printf("Texture is not support on the device\n");
passed();
}
#ifdef _WIN32
testResult = runTest(argc, argv);
#else
+10 -1
View File
@@ -12,14 +12,23 @@
__global__ void tex2DKernel(float* outputData, hipTextureObject_t textureObject, int width,
int height) {
#if !defined(__HIP_NO_IMAGE_SUPPORT) || !__HIP_NO_IMAGE_SUPPORT
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
outputData[y * width + x] = tex2D<float>(textureObject, x, y);
#endif
}
int runTest(int argc, char** argv);
int main(int argc, char** argv) {
int imageSupport = 0;
hipDeviceGetAttribute(&imageSupport, hipDeviceAttributeImageSupport,
p_gpuDevice);
if (!imageSupport) {
printf("Texture is not support on the device\n");
passed();
}
int testResult = runTest(argc, argv);
if (testResult) {
@@ -70,7 +79,6 @@ int runTest(int argc, char** argv) {
// Create texture object
hipTextureObject_t textureObject = 0;
hipCreateTextureObject(&textureObject, &resDesc, &texDesc, NULL);
float* dData = NULL;
hipMalloc((void**)&dData, size);
@@ -104,5 +112,6 @@ int runTest(int argc, char** argv) {
hipDestroyTextureObject(textureObject);
hipFree(dData);
hipFreeArray(hipArray);
free(hData);
return testResult;
}
+9
View File
@@ -42,6 +42,7 @@ __global__ void simpleKernel3DArray(T* outputData,
int width,
int height,int depth)
{
#if !defined(__HIP_NO_IMAGE_SUPPORT) || !__HIP_NO_IMAGE_SUPPORT
for (int i = 0; i < depth; i++) {
for (int j = 0; j < height; j++) {
for (int k = 0; k < width; k++) {
@@ -54,6 +55,7 @@ __global__ void simpleKernel3DArray(T* outputData,
}
}
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
@@ -127,6 +129,13 @@ void runTest(int width,int height,int depth,texture<T, hipTextureType3D, hipRead
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
int imageSupport = 0;
hipDeviceGetAttribute(&imageSupport, hipDeviceAttributeImageSupport,
p_gpuDevice);
if (!imageSupport) {
printf("Texture is not support on the device\n");
passed();
}
printf("%s starting...\n", sampleName);
for(int i=1;i<25;i++)
{