mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-26 08:49:02 +00:00
Fix leaking memory and add enum for address spaces (#435)
Test was not cleanig up all of the kernels and programs that it creates, which results in our driver finding that the common context still has references when exiting. The reason for not cleaning all kernels and programs was that it used a hard-coded constant 3 instead of the actual number of address spaces. This fixes the leak, and makes the code a little clearer by adding an enum describing each address space, rather than using magic numbers. Signed-off-by: Mats Petersson <mats.petersson@arm.com>
This commit is contained in:
committed by
Kévin Petit
parent
e6d15a2bfc
commit
93a1dc3a3a
@@ -20,8 +20,6 @@
|
|||||||
#include "cl_utils.h"
|
#include "cl_utils.h"
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
|
||||||
extern const char *addressSpaceNames[];
|
|
||||||
|
|
||||||
static inline float half2float( cl_ushort us )
|
static inline float half2float( cl_ushort us )
|
||||||
{
|
{
|
||||||
uint32_t u = us;
|
uint32_t u = us;
|
||||||
@@ -65,8 +63,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
{
|
{
|
||||||
cl_int error;
|
cl_int error;
|
||||||
int vectorSize;
|
int vectorSize;
|
||||||
cl_program programs[kVectorSizeCount+kStrangeVectorSizeCount][4] = {{0}};
|
cl_program programs[kVectorSizeCount+kStrangeVectorSizeCount][AS_NumAddressSpaces] = {{0}};
|
||||||
cl_kernel kernels[kVectorSizeCount+kStrangeVectorSizeCount][4] = {{0}};
|
cl_kernel kernels[kVectorSizeCount+kStrangeVectorSizeCount][AS_NumAddressSpaces] = {{0}};
|
||||||
uint64_t time[kVectorSizeCount+kStrangeVectorSizeCount] = {0};
|
uint64_t time[kVectorSizeCount+kStrangeVectorSizeCount] = {0};
|
||||||
uint64_t min_time[kVectorSizeCount+kStrangeVectorSizeCount] = {0};
|
uint64_t min_time[kVectorSizeCount+kStrangeVectorSizeCount] = {0};
|
||||||
size_t q;
|
size_t q;
|
||||||
@@ -299,8 +297,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
|
|
||||||
|
|
||||||
if(g_arrVecSizes[vectorSize] != 3) {
|
if(g_arrVecSizes[vectorSize] != 3) {
|
||||||
programs[vectorSize][0] = MakeProgram( device, source, sizeof( source) / sizeof( source[0]) );
|
programs[vectorSize][AS_Global] = MakeProgram( device, source, sizeof( source) / sizeof( source[0]) );
|
||||||
if( NULL == programs[ vectorSize ][0] ) {
|
if( NULL == programs[ vectorSize ][AS_Global] ) {
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create program.\n" );
|
vlog_error( "\t\tFAILED -- Failed to create program.\n" );
|
||||||
for ( q= 0; q < sizeof( source) / sizeof( source[0]); q++)
|
for ( q= 0; q < sizeof( source) / sizeof( source[0]); q++)
|
||||||
@@ -309,8 +307,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
} else if(aligned) {
|
} else if(aligned) {
|
||||||
programs[vectorSize][0] = MakeProgram( device, sourceV3aligned, sizeof( sourceV3aligned) / sizeof( sourceV3aligned[0]) );
|
programs[vectorSize][AS_Global] = MakeProgram( device, sourceV3aligned, sizeof( sourceV3aligned) / sizeof( sourceV3aligned[0]) );
|
||||||
if( NULL == programs[ vectorSize ][0] ) {
|
if( NULL == programs[ vectorSize ][AS_Global] ) {
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create program.\n" );
|
vlog_error( "\t\tFAILED -- Failed to create program.\n" );
|
||||||
for ( q= 0; q < sizeof( sourceV3aligned) / sizeof( sourceV3aligned[0]); q++)
|
for ( q= 0; q < sizeof( sourceV3aligned) / sizeof( sourceV3aligned[0]); q++)
|
||||||
@@ -319,8 +317,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
programs[vectorSize][0] = MakeProgram( device, sourceV3, sizeof( sourceV3) / sizeof( sourceV3[0]) );
|
programs[vectorSize][AS_Global] = MakeProgram( device, sourceV3, sizeof( sourceV3) / sizeof( sourceV3[0]) );
|
||||||
if( NULL == programs[ vectorSize ][0] ) {
|
if( NULL == programs[ vectorSize ][AS_Global] ) {
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create program.\n" );
|
vlog_error( "\t\tFAILED -- Failed to create program.\n" );
|
||||||
for ( q= 0; q < sizeof( sourceV3) / sizeof( sourceV3[0]); q++)
|
for ( q= 0; q < sizeof( sourceV3) / sizeof( sourceV3[0]); q++)
|
||||||
@@ -329,8 +327,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kernels[ vectorSize ][0] = clCreateKernel( programs[ vectorSize ][0], "test", &error );
|
kernels[ vectorSize ][AS_Global] = clCreateKernel( programs[ vectorSize ][AS_Global], "test", &error );
|
||||||
if( NULL == kernels[vectorSize][0] )
|
if( NULL == kernels[vectorSize][AS_Global] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create kernel. (%d)\n", error );
|
vlog_error( "\t\tFAILED -- Failed to create kernel. (%d)\n", error );
|
||||||
@@ -354,8 +352,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
source_ptr = source_private2;
|
source_ptr = source_private2;
|
||||||
source_size = sizeof( source_private2) / sizeof( source_private2[0]);
|
source_size = sizeof( source_private2) / sizeof( source_private2[0]);
|
||||||
}
|
}
|
||||||
programs[vectorSize][1] = MakeProgram( device, source_ptr, source_size );
|
programs[vectorSize][AS_Private] = MakeProgram( device, source_ptr, source_size );
|
||||||
if( NULL == programs[ vectorSize ][1] )
|
if( NULL == programs[ vectorSize ][AS_Private] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create private program.\n" );
|
vlog_error( "\t\tFAILED -- Failed to create private program.\n" );
|
||||||
@@ -364,8 +362,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
kernels[ vectorSize ][1] = clCreateKernel( programs[ vectorSize ][1], "test", &error );
|
kernels[ vectorSize ][AS_Private] = clCreateKernel( programs[ vectorSize ][AS_Private], "test", &error );
|
||||||
if( NULL == kernels[vectorSize][1] )
|
if( NULL == kernels[vectorSize][AS_Private] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create private kernel. (%d)\n", error );
|
vlog_error( "\t\tFAILED -- Failed to create private kernel. (%d)\n", error );
|
||||||
@@ -387,8 +385,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
source_ptr = source_local2;
|
source_ptr = source_local2;
|
||||||
source_size = sizeof( source_local2) / sizeof( source_local2[0]);
|
source_size = sizeof( source_local2) / sizeof( source_local2[0]);
|
||||||
}
|
}
|
||||||
programs[vectorSize][2] = MakeProgram( device, source_ptr, source_size );
|
programs[vectorSize][AS_Local] = MakeProgram( device, source_ptr, source_size );
|
||||||
if( NULL == programs[ vectorSize ][2] )
|
if( NULL == programs[ vectorSize ][AS_Local] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create local program.\n" );
|
vlog_error( "\t\tFAILED -- Failed to create local program.\n" );
|
||||||
@@ -397,8 +395,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
kernels[ vectorSize ][2] = clCreateKernel( programs[ vectorSize ][2], "test", &error );
|
kernels[ vectorSize ][AS_Local] = clCreateKernel( programs[ vectorSize ][AS_Local], "test", &error );
|
||||||
if( NULL == kernels[vectorSize][2] )
|
if( NULL == kernels[vectorSize][AS_Local] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create local kernel. (%d)\n", error );
|
vlog_error( "\t\tFAILED -- Failed to create local kernel. (%d)\n", error );
|
||||||
@@ -407,8 +405,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
|
|
||||||
if(g_arrVecSizes[vectorSize] == 3) {
|
if(g_arrVecSizes[vectorSize] == 3) {
|
||||||
if(aligned) {
|
if(aligned) {
|
||||||
programs[vectorSize][3] = MakeProgram( device, source_constantV3aligned, sizeof(source_constantV3aligned) / sizeof( source_constantV3aligned[0]) );
|
programs[vectorSize][AS_Constant] = MakeProgram( device, source_constantV3aligned, sizeof(source_constantV3aligned) / sizeof( source_constantV3aligned[0]) );
|
||||||
if( NULL == programs[ vectorSize ][3] )
|
if( NULL == programs[ vectorSize ][AS_Constant] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create constant program.\n" );
|
vlog_error( "\t\tFAILED -- Failed to create constant program.\n" );
|
||||||
@@ -417,8 +415,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
programs[vectorSize][3] = MakeProgram( device, source_constantV3, sizeof(source_constantV3) / sizeof( source_constantV3[0]) );
|
programs[vectorSize][AS_Constant] = MakeProgram( device, source_constantV3, sizeof(source_constantV3) / sizeof( source_constantV3[0]) );
|
||||||
if( NULL == programs[ vectorSize ][3] )
|
if( NULL == programs[ vectorSize ][AS_Constant] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create constant program.\n" );
|
vlog_error( "\t\tFAILED -- Failed to create constant program.\n" );
|
||||||
@@ -428,8 +426,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
programs[vectorSize][3] = MakeProgram( device, source_constant, sizeof(source_constant) / sizeof( source_constant[0]) );
|
programs[vectorSize][AS_Constant] = MakeProgram( device, source_constant, sizeof(source_constant) / sizeof( source_constant[0]) );
|
||||||
if( NULL == programs[ vectorSize ][3] )
|
if( NULL == programs[ vectorSize ][AS_Constant] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create constant program.\n" );
|
vlog_error( "\t\tFAILED -- Failed to create constant program.\n" );
|
||||||
@@ -439,8 +437,8 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kernels[ vectorSize ][3] = clCreateKernel( programs[ vectorSize ][3], "test", &error );
|
kernels[ vectorSize ][AS_Constant] = clCreateKernel( programs[ vectorSize ][AS_Constant], "test", &error );
|
||||||
if( NULL == kernels[vectorSize][3] )
|
if( NULL == kernels[vectorSize][AS_Constant] )
|
||||||
{
|
{
|
||||||
gFailCount++;
|
gFailCount++;
|
||||||
vlog_error( "\t\tFAILED -- Failed to create constant kernel. (%d)\n", error );
|
vlog_error( "\t\tFAILED -- Failed to create constant kernel. (%d)\n", error );
|
||||||
@@ -491,7 +489,7 @@ int Test_vLoadHalf_private( cl_device_id device, bool aligned )
|
|||||||
for( vectorSize = minVectorSize; vectorSize < kLastVectorSizeToTest; vectorSize++)
|
for( vectorSize = minVectorSize; vectorSize < kLastVectorSizeToTest; vectorSize++)
|
||||||
{ // here we loop through vector sizes, 3 is last
|
{ // here we loop through vector sizes, 3 is last
|
||||||
|
|
||||||
for ( addressSpace = 0; addressSpace < 4; addressSpace++) {
|
for ( addressSpace = 0; addressSpace < AS_NumAddressSpaces; addressSpace++) {
|
||||||
uint32_t pattern = 0x7fffdead;
|
uint32_t pattern = 0x7fffdead;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -604,7 +602,7 @@ exit:
|
|||||||
//clean up
|
//clean up
|
||||||
for( vectorSize = minVectorSize; vectorSize < kLastVectorSizeToTest; vectorSize++)
|
for( vectorSize = minVectorSize; vectorSize < kLastVectorSizeToTest; vectorSize++)
|
||||||
{
|
{
|
||||||
for ( addressSpace = 0; addressSpace < 3; addressSpace++) {
|
for ( addressSpace = 0; addressSpace < AS_NumAddressSpaces; addressSpace++) {
|
||||||
clReleaseKernel( kernels[ vectorSize ][addressSpace] );
|
clReleaseKernel( kernels[ vectorSize ][addressSpace] );
|
||||||
clReleaseProgram( programs[ vectorSize ][addressSpace] );
|
clReleaseProgram( programs[ vectorSize ][addressSpace] );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
#include "cl_utils.h"
|
#include "cl_utils.h"
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
|
||||||
extern const char *addressSpaceNames[];
|
|
||||||
|
|
||||||
typedef struct ComputeReferenceInfoF_
|
typedef struct ComputeReferenceInfoF_
|
||||||
{
|
{
|
||||||
float *x;
|
float *x;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
const char ** argList = NULL;
|
const char ** argList = NULL;
|
||||||
size_t argCount = 0;
|
size_t argCount = 0;
|
||||||
char appName[64] = "ctest";
|
char appName[64] = "ctest";
|
||||||
const char *addressSpaceNames[] = {"global", "private", "local", "constant"};
|
const char *addressSpaceNames[AS_NumAddressSpaces] = {"global", "private", "local", "constant"};
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Declarations
|
#pragma mark Declarations
|
||||||
|
|||||||
@@ -16,6 +16,17 @@
|
|||||||
#ifndef TESTS_H
|
#ifndef TESTS_H
|
||||||
#define TESTS_H
|
#define TESTS_H
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
AS_Global,
|
||||||
|
AS_Private,
|
||||||
|
AS_Local,
|
||||||
|
AS_Constant,
|
||||||
|
AS_NumAddressSpaces
|
||||||
|
} AddressSpaceEnum;
|
||||||
|
|
||||||
|
extern const char *addressSpaceNames[AS_NumAddressSpaces];
|
||||||
|
|
||||||
|
|
||||||
int test_vload_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
int test_vload_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||||
int test_vloada_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
int test_vloada_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
|
||||||
|
|||||||
Reference in New Issue
Block a user