Hi,
I m trying to compile a very simple threaded app using the Intel Composer XE beta 2015. The program compiles just fine on a Linux platform but fails on latest Mac OS X:
Sample program: threaded_cpp
#include <cmath>
#include <iostream>
#include <thread>
#include <vector>
using namespace std;
void f(int start, int end, float* input, float* output){
for(int i=start; i != end; ++i){
output[i] = sqrt(sin(input[i])*sin(input[i]+cos(input[i])*cos(input[i])));
}
}
int main(){
const int data_size = 100000000;
float* input = new float[data_size];
float* output = new float[data_size];
for(int i=0; i<data_size; ++i){
input[i] = i;
}
const int num_threads = std::thread::hardware_concurrency();
std::vector<std::thread> threads;
const int block_size = data_size/num_threads;
int start = 0;
for (int i=0; i < (num_threads-1); ++i){
threads.push_back(std::thread(f, start, start+block_size, input, output));
start = start + block_size;
}
f(start, data_size, input, output);
for(auto& thread : threads){
thread.join();
}
delete[] input;
delete[] output;
}
compile command: icpc -std=c++11 -no-vec threaded_for.cpp -o threaded_for
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/tuple(452): error: pack expansion does not make use of any argument packs
operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
^
detected during:
instantiation of class "std::__1::__tuple_impl<std::__1::__tuple_indices<_Indx...>, _Tp...> [with _Indx=<0UL, 1UL, 2UL, 3UL, 4UL>, _Tp=<void (*)(int, int, float *, float *), int, int, float *, float *>]" at line 492
instantiation of class "std::__1::tuple<_Tp...> [with _Tp=<void (*)(int, int, float *, float *), int, int, float *, float *>]" at line 352 of "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/thread"
instantiation of "std::__1::thread::thread(_Fp &&, _Args &&...) [with _Fp=void (&)(int, int, float *, float *), _Args=<int &, int, float *&, float *&>, <unnamed>=void]" at line 34 of "threaded_for.cpp"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/tuple(425): error: pack expansion does not make use of any argument packs
__tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
^
detected during:
instantiation of class "std::__1::__tuple_impl<std::__1::__tuple_indices<_Indx...>, _Tp...> [with _Indx=<0UL, 1UL, 2UL, 3UL, 4UL>, _Tp=<void (*)(int, int, float *, float *), int, int, float *, float *>]" at line 492
instantiation of class "std::__1::tuple<_Tp...> [with _Tp=<void (*)(int, int, float *, float *), int, int, float *, float *>]" at line 352 of "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/thread"
instantiation of "std::__1::thread::thread(_Fp &&, _Args &&...) [with _Fp=void (&)(int, int, float *, float *), _Args=<int &, int, float *&, float *&>, <unnamed>=void]" at line 34 of "threaded_for.cpp"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/tuple(584): error: the operand of sizeof... must be a parameter pack name
_NOEXCEPT_((
^
detected during:
instantiation of class "std::__1::tuple<_Tp...> [with _Tp=<void (*)(int, int, float *, float *), int, int, float *, float *>]" at line 352 of "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/thread"
instantiation of "std::__1::thread::thread(_Fp &&, _Args &&...) [with _Fp=void (&)(int, int, float *, float *), _Args=<int &, int, float *&, float *&>, <unnamed>=void]" at line 34 of "threaded_for.cpp"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/tuple(543): error: the operand of sizeof... must be a parameter pack name
_NOEXCEPT_((
^
detected during:
instantiation of class "std::__1::tuple<_Tp...> [with _Tp=<void (*)(int, int, float *, float *), int, int, float *, float *>]" at line 352 of "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/thread"
instantiation of "std::__1::thread::thread(_Fp &&, _Args &&...) [with _Fp=void (&)(int, int, float *, float *), _Args=<int &, int, float *&, float *&>, <unnamed>=void]" at line 34 of "threaded_for.cpp"
compilation aborted for threaded_for.cpp (code 2)