mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Make wimpy factor argument parsing logic common (#155)
This commit is contained in:
committed by
Kévin Petit
parent
8d209840be
commit
c1cd117265
@@ -127,3 +127,27 @@ int parseCustomParam (int argc, const char *argv[], const char *ignore)
|
||||
}
|
||||
return argc;
|
||||
}
|
||||
|
||||
bool is_power_of_two(int number)
|
||||
{
|
||||
return number && !(number & (number - 1));
|
||||
}
|
||||
|
||||
extern void parseWimpyReductionFactor(const char *&arg, int &wimpyReductionFactor)
|
||||
{
|
||||
const char *arg_temp = strchr(&arg[1], ']');
|
||||
if (arg_temp != 0)
|
||||
{
|
||||
int new_factor = atoi(&arg[1]);
|
||||
arg = arg_temp; // Advance until ']'
|
||||
if (is_power_of_two(new_factor))
|
||||
{
|
||||
log_info("\n Wimpy reduction factor changed from %d to %d \n", wimpyReductionFactor, new_factor);
|
||||
wimpyReductionFactor = new_factor;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("\n WARNING: Incorrect wimpy reduction factor %d, must be power of 2. The default value will be used.\n", new_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#ifndef _parseParameters_h
|
||||
#define _parseParameters_h
|
||||
|
||||
#include "compat.h"
|
||||
#include <string>
|
||||
|
||||
extern bool gOfflineCompiler;
|
||||
@@ -34,4 +35,6 @@ extern OfflineCompilerOutputType gOfflineCompilerOutputType;
|
||||
|
||||
extern int parseCustomParam (int argc, const char *argv[], const char *ignore = 0 );
|
||||
|
||||
extern void parseWimpyReductionFactor(const char *&arg, int &wimpyReductionFactor);
|
||||
|
||||
#endif // _parseParameters_h
|
||||
|
||||
Reference in New Issue
Block a user