-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Remove /proc/cpuinfo fallback path #1921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
} | ||
return num_cpus; | ||
// Fallback, no other API exists. | ||
return -1; |
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.
Should this be
#error Don't know how to detect CPU count for this platform?
?
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.
Well the original code would build even if it would not return an appropriate value.
Depends what the intent is.
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.
That's what i'm asking, yes. It does seem like a situation that should be loudly reported.
Actually, for that, we wouldn't need the return:
#else
#error Don't know how to detect CPU count for this platform
#endif
BENCHMARK_UNREACHABLE();
}
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.
we had this as a "soft error" only because there are so many platforms out there, and this at least returns 1 CPU in the case that we can't identify it (and logs a thing). i'm not sure we have good enough coverage yet to make it an error but if you all are confident, go for it.
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.
I guess I was figuring going with the soft error. Maybe slightly tweak the other error message to mention the need for additional OS support after this.
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.
It would be a loud compile-time error that can not be missed,
not a run-time error that you might not notice when packaging,
so i think it would be more safe than the current more-than-silent error...
I'd do it. Especially if we are confident that this fallback is no longer needed.
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.
what it means is that any clients that need platform support will now find out. that may be good or bad, but basic platform support will be "return 1" within an appropriate platform define so that's easy enough.
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.
Anyways, i've made my point. Deferring to @dmah42.
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.
i'm happy to keep the soft error. i usually prefer hard errors but i don't really want an influx of random platforms needing support for their way to get CPU.
if we think the new version handles all cases (or should handle all cases) then we can switch it.
AIX, WASM (fork of musl for libc) and a few others should now use the sysconf path. /proc is not portable and cpuinfo is Linux specific. It does not work anywhere else.
958c0df
to
f9867b7
Compare
AIX, WASM (fork of musl for libc) and a few others should now use the sysconf
path. /proc is not portable and cpuinfo is Linux specific. It does not work
anywhere else.