Skip to content

Commit

Permalink
[NFC] math_brute_force: drop unneeded gotos (#1843)
Browse files Browse the repository at this point in the history
Simplify code by returning directly instead of using goto statements.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
  • Loading branch information
svenvh committed Jun 27, 2024
1 parent c7b682f commit fcbccab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
14 changes: 6 additions & 8 deletions test_conformance/math_brute_force/i_unary_double.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode)
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
return error;
}
}
else
Expand All @@ -124,21 +124,21 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode)
sizeof(gOutBuffer[j]), &gOutBuffer[j])))
{
LogBuildError(programs[j]);
goto exit;
return error;
}
if ((error = clSetKernelArg(kernels[j][thread_id], 1,
sizeof(gInBuffer), &gInBuffer)))
{
LogBuildError(programs[j]);
goto exit;
return error;
}

if ((error = clEnqueueNDRangeKernel(gQueue, kernels[j][thread_id],
1, NULL, &localCount, NULL, 0,
NULL, NULL)))
{
vlog_error("FAILED -- could not execute kernel\n");
goto exit;
return error;
}
}

Expand All @@ -159,7 +159,7 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode)
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{
vlog_error("ReadArray failed %d\n", error);
goto exit;
return error;
}
}

Expand Down Expand Up @@ -188,8 +188,7 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode)
"\nERROR: %sD%s: %d ulp error at %.13la: *%d vs. %d\n",
f->name, sizeNames[k], err, ((double *)gIn)[j], t[j],
q[j]);
error = -1;
goto exit;
return -1;
}
}
}
Expand Down Expand Up @@ -221,6 +220,5 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode)

vlog("\n");

exit:
return error;
}
14 changes: 6 additions & 8 deletions test_conformance/math_brute_force/i_unary_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode)
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
return error;
}
}
else
Expand All @@ -123,21 +123,21 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode)
sizeof(gOutBuffer[j]), &gOutBuffer[j])))
{
LogBuildError(programs[j]);
goto exit;
return error;
}
if ((error = clSetKernelArg(kernels[j][thread_id], 1,
sizeof(gInBuffer), &gInBuffer)))
{
LogBuildError(programs[j]);
goto exit;
return error;
}

if ((error = clEnqueueNDRangeKernel(gQueue, kernels[j][thread_id],
1, NULL, &localCount, NULL, 0,
NULL, NULL)))
{
vlog_error("FAILED -- could not execute kernel\n");
goto exit;
return error;
}
}

Expand All @@ -158,7 +158,7 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode)
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{
vlog_error("ReadArray failed %d\n", error);
goto exit;
return error;
}
}

Expand Down Expand Up @@ -187,8 +187,7 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode)
"*%d vs. %d\n",
f->name, sizeNames[k], err, ((float *)gIn)[j],
((cl_uint *)gIn)[j], t[j], q[j]);
error = -1;
goto exit;
return -1;
}
}
}
Expand Down Expand Up @@ -219,6 +218,5 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode)

vlog("\n");

exit:
return error;
}

0 comments on commit fcbccab

Please sign in to comment.