Build issues
mscha opened this issue · 4 comments
I had v0.1 installed without issues. But v0.2 didn't go so smoothly:
- I had primesieve 5.7 installed. Looks like v0,2 requires primesieve 6.0 – the iterator test gave an error about not finding a symbol in the library. (Unfortunately no longer in my scroll buffer.)
You may way to document and explicitly test for primesieve 6.0 or higher.
- After installing primesieve 6.0, I got the following errors:
# Failed test 'get num-threads'
# at t/01.basic.t line 13
# expected: '2'
# got: '1'
# Failed test 'set num-threads'
# at t/01.basic.t line 17
# expected: '4'
# got: '1'
Looks like threading doesn't work on my machine, for some reason.
This didn't seem like a fatal problem, so I installed with --force. Seems to work fine (as long as I don't use threading, I guess).
Perhaps these tests make assumptions they shouldn't?
Thanks for providing this awesome module!
– Michael
Can you please share your operating system version and your C++ compiler version?
primesieve-6.0 uses C++11 threads instead of OpenMP. I read on the web that the C++11 threading functionality was unable to detect the number of CPU cores for older versions of GCC (<= 4.8) but personally I have not come across these issues yet.
Ubuntu 12.04.5 LTS. (Yes, I need to upgrade...)
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Indeed, ≤ 4.8.
Thanks!
primesieve-6.0 uses the following C++11 code to detect the number of CPU cores:
int max_threads = thread::hardware_concurrency();
Old versions of GCC which do not properly support C++11 simply return 0 (GCC < 4.7 ?!) as described by this stackoverflow post: http://stackoverflow.com/a/8583292/363778
I was aware of this limitation when writing primesieve-6.0 but since I was not aware of any portable workaround I decided to leave the code as is. This is a minor issue I won't fix.
Instead I suggest to remove the perl tests below:
ok my $p = Math::Primesieve.new(num-threads => 2,
sieve-size => 4), 'new';
is $p.num-threads, 2, 'get num-threads';
$p.num-threads(4);
is $p.num-threads, 4, 'set num-threads';
Testing the get_num_threads()
and set_num_threads()
functionality will break on systems with only 1 CPU core as primesieve uses the following code to limit the number of threads to the number of CPU cores (<= getMaxThreads()
):
void set_num_threads(int threads)
{
num_threads = inBetween(1, threads, ParallelPrimeSieve::getMaxThreads());
}
I removed those tests.