mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Reduce scope of variables (#1228)
Make variables local to loops, with appropriate types. These variables are not read after the loop without being reset first, so this patch doesn't change behaviour. These variables should now be used for one purpose only, making it easier to reason about the code. This will make future refactoring easier. Signed-off-by: Marco Antognini <marco.antognini@arm.com>
This commit is contained in:
@@ -132,8 +132,6 @@ static cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
|
||||
|
||||
int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
{
|
||||
uint64_t i;
|
||||
uint32_t j, k;
|
||||
int error;
|
||||
cl_program programs[VECTOR_SIZE_COUNT];
|
||||
cl_kernel kernels[VECTOR_SIZE_COUNT];
|
||||
@@ -155,13 +153,13 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
return error;
|
||||
}
|
||||
|
||||
for (i = 0; i < (1ULL << 32); i += step)
|
||||
for (uint64_t i = 0; i < (1ULL << 32); i += step)
|
||||
{
|
||||
// Init input array
|
||||
double *p = (double *)gIn;
|
||||
double *p2 = (double *)gIn2;
|
||||
double *p3 = (double *)gIn3;
|
||||
for (j = 0; j < BUFFER_SIZE / sizeof(double); j++)
|
||||
for (size_t j = 0; j < BUFFER_SIZE / sizeof(double); j++)
|
||||
{
|
||||
p[j] = DoubleFromUInt32(genrand_int32(d));
|
||||
p2[j] = DoubleFromUInt32(genrand_int32(d));
|
||||
@@ -190,7 +188,7 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
}
|
||||
|
||||
// write garbage into output arrays
|
||||
for (j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
{
|
||||
uint32_t pattern = 0xffffdead;
|
||||
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
|
||||
@@ -205,7 +203,7 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
}
|
||||
|
||||
// Run the kernels
|
||||
for (j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
{
|
||||
size_t vectorSize = sizeof(cl_double) * sizeValues[j];
|
||||
size_t localCount = (BUFFER_SIZE + vectorSize - 1)
|
||||
@@ -252,11 +250,11 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
double *s = (double *)gIn;
|
||||
double *s2 = (double *)gIn2;
|
||||
double *s3 = (double *)gIn3;
|
||||
for (j = 0; j < BUFFER_SIZE / sizeof(double); j++)
|
||||
for (size_t j = 0; j < BUFFER_SIZE / sizeof(double); j++)
|
||||
r[j] = (double)f->dfunc.f_fff(s[j], s2[j], s3[j]);
|
||||
|
||||
// Read the data back
|
||||
for (j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
{
|
||||
if ((error =
|
||||
clEnqueueReadBuffer(gQueue, gOutBuffer[j], CL_TRUE, 0,
|
||||
@@ -293,7 +291,7 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
|
||||
exit:
|
||||
// Release
|
||||
for (k = gMinVectorSizeIndex; k < gMaxVectorSizeIndex; k++)
|
||||
for (auto k = gMinVectorSizeIndex; k < gMaxVectorSizeIndex; k++)
|
||||
{
|
||||
clReleaseKernel(kernels[k]);
|
||||
clReleaseProgram(programs[k]);
|
||||
|
||||
Reference in New Issue
Block a user