/* ispc -O2 --target=avx1-i32x8 --arch=x86-64 sinx_ispc.ispc -o sinx_ispc.o -h sinx_ispc.h g++ -mavx -std=c++11 sinx_ispc_main.cpp sinx_ispc.o */ #include "sinx_ispc.h" #include #include #include void my_thread_start(int N, int terms, float *x, float *results) { ispc::sinx(N, terms, x, results); // do work } int main() { std::array input = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::array result; int N = 10; int half = N / 2; float *input_ptr = (float *)(&input); float *result_ptr = (float *)(&result); // launch thread to do work on first half of array std::thread t1(my_thread_start, half, 20, input_ptr, result_ptr); // do work on second half of array in main thread ispc::sinx(N - half, 20, &input_ptr[half], &result_ptr[half]); t1.join(); for (int i = 0; i < 10; i++) { std::cout << "sin(" << input[i] << ") = " << result[i] << "\n"; } return 0; }