Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Use sysconf(_SC_NPROCESSORS_CONF) in PAL and GC ONLY on ARM and ARM64 #18289

Merged
merged 1 commit into from
Jun 5, 2018
Merged

Use sysconf(_SC_NPROCESSORS_CONF) in PAL and GC ONLY on ARM and ARM64 #18289

merged 1 commit into from
Jun 5, 2018

Conversation

echesakov
Copy link

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

@echesakov
Copy link
Author

@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test
@dotnet-bot test Ubuntu arm Cross Checked corefx_baseline Build and Test


#if defined(_ARM_) || defined(_ARM64_)
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
#define SYSCONF_GET_NUMPROCS_NAME "_SC_NPROCESSORS_CONF"
Copy link
Member

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); 

Copy link
Author

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

Copy link
Member

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.

@echesakov
Copy link
Author

It seems that failure in Ubuntu arm Cross Checked corefx_baseline Build and Test happened before. I opened a corresponding issue #18295

@echesakov echesakov merged commit 79aadb8 into dotnet:master Jun 5, 2018
@echesakov echesakov deleted the UseSysConfNumProcsConfOnArmArchOnly branch June 5, 2018 18:39
stephentoub pushed a commit to dotnet/corefx that referenced this pull request Jun 5, 2018
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants