This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer] Diff 9 - 2 - Properly use unsigned for workers, jobs and NumberOfCpuCores.
ClosedPublic

Authored by mpividori on Dec 12 2016, 1:43 PM.

Details

Summary

According to amccarth's suggestions in: https://reviews.llvm.org/D27234?id=79657#inline-234115 , I modify NumberOfCpuCores() to return unsigned.

The number of cpus is used to define the number of workers in:

Flags.workers = std::min(NumberOfCpuCores() / 2, Flags.jobs);

So, I decided to update the worker and jobs flags to be defined as unsigned. These are not strictly necessary changes, I could have casted the result of the division to int, as :

Flags.workers = std::min(int(NumberOfCpuCores() / 2), Flags.jobs);

But I decided it would be better to avoid that and properly use unsigned for workers and jobs.

Diff Detail

Repository
rL LLVM

Event Timeline

mpividori updated this revision to Diff 81132.Dec 12 2016, 1:43 PM
mpividori retitled this revision from to [libFuzzer] Diff 9 - 2 - Properly use unsigned for workers, jobs and NumberOfCpuCores..
mpividori updated this object.
mpividori added reviewers: kcc, zturner, amccarth.
mpividori set the repository for this revision to rL LLVM.
mpividori added a subscriber: llvm-commits.
kcc edited edge metadata.Dec 12 2016, 2:05 PM

again: what problem are you trying to solve?

@kcc std::thread::hardware_concurrency() returns unsigned, so NumberOfCpuCores() should return unsigned. Would you agree on this?
As NumberOfCpuCores() returns unsigned I thought it would be more appropriate to use unsigned for jobs and workers. If you don't want that changes, I can use an explicit cast as I mentioned above.
Just let me know what you want and I will include that changes.
Thanks

kcc accepted this revision.Dec 12 2016, 2:48 PM
kcc edited edge metadata.

LGTM
(got it!)

This revision is now accepted and ready to land.Dec 12 2016, 2:48 PM
This revision was automatically updated to reflect the committed changes.