Detection of system features for number of sockets #245 (#246)

* Configure checks for architecture-specific functions to detect nr of sockets. #245
master
Julian Kunkel 2020-08-03 12:30:21 +01:00 committed by GitHub
parent 47b63a8054
commit 4e2d179052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 8 deletions

View File

@ -400,6 +400,30 @@ Consider --with-aws4c=, CPPFLAGS, LDFLAGS, etc])
LDFLAGS=$ORIG_LDFLAGS
])
# Check for existence of the function to detect the CPU socket ID (for multi-socket systems)
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([[
int main(){
unsigned long a,d,c;
__asm__ volatile("rdtscp" : "=a" (a), "=d" (d), "=c" (c));
return 0;
}
]])],
AC_DEFINE([HAVE_RDTSCP_ASM], [], [Has ASM to detect CPU socket ID]))
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([[
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
unsigned long GetProcessorAndCore(int *chip, int *core){
return syscall(SYS_getcpu, core, chip, NULL);
}
int main(){
}
]])],
AC_DEFINE([HAVE_GETCPU_SYSCALL], [], [Has syscall to detect CPU socket ID]))
# Enable building "IOR", in all capitals
AC_ARG_ENABLE([caps],

View File

@ -792,8 +792,7 @@ void GetTestFileName(char *testFileName, IOR_param_t * test)
strcpy(initialTestFileName, test->testFileName);
if(test->dualMount){
GetProcessorAndCore(&socket, &core);
sprintf(tmpString, "%s%d/%s",initialTestFileName,
socket, "data");
sprintf(tmpString, "%s%d/%s",initialTestFileName, socket, "data");
strcpy(initialTestFileName, tmpString);
}
fileNames = ParseFileName(initialTestFileName, &count);

View File

@ -16,6 +16,12 @@
# include "config.h"
#endif
#ifdef HAVE_GETCPU_SYSCALL
# define _GNU_SOURCE
# include <unistd.h>
# include <sys/syscall.h>
#endif
#ifdef __linux__
# define _GNU_SOURCE /* Needed for O_DIRECT in fcntl */
#endif /* __linux__ */
@ -869,17 +875,15 @@ char *HumanReadable(IOR_offset_t value, int base)
return valueStr;
}
#if defined(__aarch64__)
// TODO: This might be general enough to provide the functionality for any system
// regardless of processor type given we aren't worried about thread/process migration.
#if defined(HAVE_GETCPU_SYSCALL)
// Assume we aren't worried about thread/process migration.
// Test on Intel systems and see if we can get rid of the architecture specificity
// of the code.
unsigned long GetProcessorAndCore(int *chip, int *core){
return syscall(SYS_getcpu, core, chip, NULL);
}
// TODO: Add in AMD function
#else
// If we're not on an ARM processor assume we're on an intel processor and use the
#elif defined(HAVE_RDTSCP_ASM)
// We're on an intel processor and use the
// rdtscp instruction.
unsigned long GetProcessorAndCore(int *chip, int *core){
unsigned long a,d,c;
@ -888,4 +892,12 @@ unsigned long GetProcessorAndCore(int *chip, int *core){
*core = c & 0xFFF;
return ((unsigned long)a) | (((unsigned long)d) << 32);;
}
#else
// TODO: Add in AMD function
unsigned long GetProcessorAndCore(int *chip, int *core){
#warning GetProcessorAndCore is implemented as a dummy
*chip = 0;
*core = 0;
return 1;
}
#endif