[NFC] math_brute_force: move TestInfoBase to common.h (#2059)

The various forms of `TestInfoBase` have many members in common, so
avoid duplicating the struct definition and move it to `common.h`.

Provide a description and initializer for every struct member, and drop
initializations done with `memset`.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
Sven van Haastregt
2024-09-03 19:30:13 +02:00
committed by GitHub
parent eb7a30ae42
commit 9116bb7acb
6 changed files with 52 additions and 94 deletions

View File

@@ -45,26 +45,8 @@ typedef struct ThreadInfo
tQueue; // per thread command queue to improve performance
} ThreadInfo;
struct TestInfoBase
{
size_t subBufferSize; // Size of the sub-buffer in elements
const Func *f; // A pointer to the function info
cl_uint threadCount; // Number of worker threads
cl_uint jobCount; // Number of jobs
cl_uint step; // step between each chunk and the next.
cl_uint scale; // stride between individual test values
float ulps; // max_allowed ulps
int ftz; // non-zero if running in flush to zero mode
int isRangeLimited; // 1 if the function is only to be evaluated over a
// range
float half_sin_cos_tan_limit;
};
struct TestInfo : public TestInfoBase
{
TestInfo(const TestInfoBase &base): TestInfoBase(base) {}
// Array of thread specific information
std::vector<ThreadInfo> tinfo;
@@ -351,7 +333,6 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
int TestFunc_Half_Half(const Func *f, MTdata d, bool relaxedMode)
{
TestInfoBase test_info_base;
cl_int error;
size_t i, j;
float maxError = 0.0f;
@@ -360,8 +341,7 @@ int TestFunc_Half_Half(const Func *f, MTdata d, bool relaxedMode)
logFunctionInfo(f->name, sizeof(cl_half), relaxedMode);
// Init test_info
memset(&test_info_base, 0, sizeof(test_info_base));
TestInfo test_info(test_info_base);
TestInfo test_info;
test_info.threadCount = GetThreadCount();