-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Use sysconf(_SC_NPROCESSORS_CONF) in PAL and GC ONLY on ARM and ARM64 #18289
Use sysconf(_SC_NPROCESSORS_CONF) in PAL and GC ONLY on ARM and ARM64 #18289
Conversation
…ONLN) in PAL and GC ONLY on ARM and ARM64
@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test |
|
||
#if defined(_ARM_) || defined(_ARM64_) | ||
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF | ||
#define SYSCONF_GET_NUMPROCS_NAME "_SC_NPROCESSORS_CONF" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit - instead of defining the macro and its string version, you can define a stringification macro that will make the conversion automatically:
#define STRINGIFY1(s) #s
#define STRINGIFY(s) STRINGIFY1(s)
Then you can write the assert like this:
ASSERT("sysconf failed for %s (%d)\n", STRINGIFY(SYSCONF_GET_NUMPROCS), errno);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I though about this once but I could not justify doing stringification instead of hard-coding names of the variables.
Unfortunately, doing stringification your way would not work for this example
#define _SC_NPROCESSORS_CONF 57
#define _SC_NPROCESSORS_ONLN 58
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
//#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
#define STRINGIFY1(s) #s
#define STRINGIFY(s) STRINGIFY1(s)
int main()
{
printf("STRINGIFY(SYSCONF_GET_NUMPROCS) is %s\n", STRINGIFY(SYSCONF_GET_NUMPROCS)); // Output: STRINGIFY(SYSCONF_GET_NUMPROCS) is 57
return 0;
}
This is how SC_NPROCESSORS_CONF is defined in FreeBSD https://github.com/freebsd/freebsd/blob/06362ad468fc11671364e34ed413ea9c19d858f1/include/unistd.h#L292
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks, forget about it then.
It seems that failure in Ubuntu arm Cross Checked corefx_baseline Build and Test happened before. I opened a corresponding issue #18295 |
…essorCountTest on ARM/ARM64 (#30128) * See dotnet/coreclr#18289
…ONLN) in PAL and GC ONLY on ARM and ARM64 (dotnet/coreclr#18289) Commit migrated from dotnet/coreclr@79aadb8
…essorCountTest on ARM/ARM64 (dotnet/corefx#30128) * See dotnet/coreclr#18289 Commit migrated from dotnet/corefx@ab52915
This PR limits usage of
sysconf(_SC_NPROCESSORS_CONF)
only to ARM and ARM64 (see #18053 (comment)) in the same way it is done in Release/2.1 #18055@janvorli PTAL
/cc @RussKeldorph