Thread: std::thread::hardware_concurrency() returns 0
Posts:
117
Registered:
10/3/06
|
|
Hi!
I've started using the standard <thread> lib and compiled my program on a few platforms with different compilers and all but C++ Builder (clang) manages to return the correct number of threads supported by hardware by using
std::thread::hardware_concurrency() on all the computers I've tested it on. I know std::thread::hardware_concurrency() is only supposed to give you a hint and return 0 if it wasn't able to figure it out but since it manages to figure out the correct number in VS2017 I can't help but wondering if the std::thread::hardware_concurrency() implementation is broken in C++ Builder?
Has anyone else used it successfully?
Br,
Ted
|
|
|
Posts:
116
Registered:
1/22/98
|
|
Hi!
I've started using the standard <thread> lib and compiled my program on a few platforms with different compilers and all but C++ Builder (clang) manages to return the correct number of threads supported by hardware by using
std::thread::hardware_concurrency() on all the computers I've tested it on. I know std::thread::hardware_concurrency() is only supposed to give you a hint and return 0 if it wasn't able to figure it out but since it manages to figure out the correct number in VS2017 I can't help but wondering if the std::thread::hardware_concurrency() implementation is broken in C++ Builder?
Has anyone else used it successfully?
Br,
Ted
Yes, I have real number of threads using:
int cores_number = boost::thread::hardware_concurrency();
My application was compiled for Win64 (clang)
--
With best regards
Dr. Vladimir Zhuchko
|
|
|
|
Posts:
117
Registered:
10/3/06
|
|
I can't help but wondering if the std::thread::hardware_concurrency() implementation is broken in C++ Builder?
Has anyone else used it successfully?
Yes, I have real number of threads using:
int cores_number = boost::thread::hardware_concurrency();
My application was compiled for Win64 (clang)
I see - but that's not the implementation used in C++ Builder I think? What about if you try std::thread::hardware_concurrency() ?
My program was compiled for 32 bit but gives 0 on both 32 and 64 bit machines.
If I use std::thread::hardware_concurrency() in Visual Studio (or gcc etc) it'll give me the expected values returned, depending on where I run my program.
Br,
Ted
|
|
|
|
Posts:
116
Registered:
1/22/98
|
|
I can't help but wondering if the std::thread::hardware_concurrency() implementation is broken in C++ Builder?
Has anyone else used it successfully?
Yes, I have real number of threads using:
int cores_number = boost::thread::hardware_concurrency();
My application was compiled for Win64 (clang)
I see - but that's not the implementation used in C++ Builder I think? What about if you try std::thread::hardware_concurrency() ?
My program was compiled for 32 bit but gives 0 on both 32 and 64 bit machines.
If I use std::thread::hardware_concurrency() in Visual Studio (or gcc etc) it'll give me the expected values returned, depending on where I run my program.
Br,
Ted
Yes, with std this value is equal to zero, but with boost works fine.
I am using Cbuilder-Tokyo for my programs.
I think you can put this issue to the JIRA
--
With best regards
Dr. Vladimir Zhuchko
Edited by: Vladimir Zhuchko on Jan 24, 2018 3:16 AM
|
|
|
|
Posts:
117
Registered:
10/3/06
|
|
What about if you try std::thread::hardware_concurrency() ?
Yes, with std this value is equal to zero,
I am using Cbuilder-Tokyo for my programs.
Me too.
I think you can put this issue to the JIRA
Good idea: https://quality.embarcadero.com/browse/RSP-19821
Br,
Ted
|
|
|
|
Legend
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|
Connect with Us