Improved PrintArch functions (#595) (#601)

Moved all duplicate 'PrintArch' functions to testHarness.c
Replaced sysctl system call used in 'PrintArch' function with uname
system call

Signed-off-by: bhargavdas <bhargav_das@mentor.com>

Update testHarness.c
This commit is contained in:
Bhargav Das
2020-02-21 22:17:54 +05:30
committed by GitHub
parent 3a628cfae2
commit b2cb18073c
7 changed files with 55 additions and 248 deletions

View File

@@ -114,7 +114,6 @@ static MTdata gMTdata;
static int ParseArgs( int argc, const char **argv );
static void PrintUsage( void );
static void PrintArch(void);
test_status InitCL( cl_device_id device );
static int GetTestCase( const char *name, Type *outType, Type *inType, SaturationMode *sat, RoundingMode *round );
static int DoTest( cl_device_id device, Type outType, Type inType, SaturationMode sat, RoundingMode round, MTdata d );
@@ -527,69 +526,6 @@ static void PrintUsage( void )
vlog( "You may also pass the number of the test on which to start.\nA second number can be then passed to indicate how many tests to run\n\n" );
}
static void PrintArch( void )
{
vlog( "sizeof( void*) = %ld\n", sizeof( void *) );
#if defined( __ppc__ )
vlog( "ARCH:\tppc\n" );
#elif defined( __ppc64__ )
vlog( "ARCH:\tppc64\n" );
#elif defined( __PPC__ )
vlog( "ARCH:\tppc\n" );
#elif defined( __i386__ )
vlog( "ARCH:\ti386\n" );
#elif defined( __x86_64__ )
vlog( "ARCH:\tx86_64\n" );
#elif defined( __arm__ )
vlog( "ARCH:\tarm\n" );
// Add 64 bit support
#elif defined(__aarch64__)
vlog( "ARCH:\taarch64\n" );
#elif defined (_WIN32)
vlog( "ARCH:\tWindows\n" );
#else
#error unknown arch
#endif
#if defined( __APPLE__ )
int type = 0;
size_t typeSize = sizeof( type );
sysctlbyname( "hw.cputype", &type, &typeSize, NULL, 0 );
vlog( "cpu type:\t%d\n", type );
typeSize = sizeof( type );
sysctlbyname( "hw.cpusubtype", &type, &typeSize, NULL, 0 );
vlog( "cpu subtype:\t%d\n", type );
#elif defined( __linux__ ) && !defined(__aarch64__)
#define OSNAMESZ 100
int _sysctl(struct __sysctl_args *args );
struct __sysctl_args args;
char osname[OSNAMESZ];
size_t osnamelth;
int name[] = { CTL_KERN, KERN_OSTYPE };
memset(&args, 0, sizeof(struct __sysctl_args));
args.name = name;
args.nlen = sizeof(name)/sizeof(name[0]);
args.oldval = osname;
args.oldlenp = &osnamelth;
osnamelth = sizeof(osname);
if (syscall(SYS__sysctl, &args) == -1) {
vlog( "_sysctl error\n" );
}
else {
vlog("this machine is running %*s\n", osnamelth, osname);
}
#endif
}
static int GetTestCase( const char *name, Type *outType, Type *inType, SaturationMode *sat, RoundingMode *round )
{