using Cilk libarry by installing intel parallel X studio

138 views Asked by At

I installed Intel studio and I have Visual studio 2013 , I want to write a program that uses thread . I want to compile it by Intel , I did these steps:

  1. I create an empty project
  2. I right-clicked on the cpp source and choose using Intel compiler then I select using intel c++ for selected file and after choosing All configuration , I click On Ok button.
  3. then I right click on the Project and from intel Compiler Item I choose using Intel c++.
  4. for beeing sure I go to property manager and check configuration manager , platform must be X64. ferther more,I see in c/c++ , Optimization[Intel c++]or general[Intel c++].

So I think all setting are done correctly.but I have these errors when I write a code using Cilk/cilk.h

enter image description here

and this is the code

#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
#include <math.h>
#include <cilk/cilk.h>

using namespace std;

const long int VERYBIG = 100000;
// ***********************************************************************
int main(void)
{
    int i;
    long int j, k, sum;
    double sumx, sumy, total;
    DWORD starttime, elapsedtime;
    // -----------------------------------------------------------------------
    // Output a start message
    printf("****************None Parallel Timings for %d iterations\n\n", VERYBIG);
    // repeat experiment several times
    //  int i = 0;
    cilk_for(int i = 0; i < 6; i++)
    {
        // get
        starttime = timeGetTime();
        // reset check sum & running total
        sum = 0;
        total = 0.0;
        // Work Loop, do some work by looping VERYBIG times
        cilk_for(int j = 0; j<VERYBIG; j++)
        {
            // increment check sum
            sum += 1;
            // Calculate first arithmetic series
            sumx = 0.0;
            for (k = 0; k<j; k++)
                sumx = sumx + (double)k;
            // Calculate second arithmetic series
            sumy = 0.0;
            for (k = j; k>0; k--)
                sumy = sumy + (double)k;
            if (sumx > 0.0)total = total + 1.0 / sqrt(sumx);
            if (sumy > 0.0)total = total + 1.0 / sqrt(sumy);
        }
        // get ending time and use it to determine elapsed time
        elapsedtime = timeGetTime() - starttime;
        // report elapsed time
        printf("Time Elapsed % 10d mSecs Total = %lf Check Sum = %ld\n",
            (int)elapsedtime, total, sum);
    }
    // return integer as required by function header
    return 0;
}
// **********************************************************************

I should say that I try to use _Cilk_for instead of cilk_for but the problem wasn't solved.

Could anybody tell me what is the problem ?

1

There are 1 answers

4
codeling On BEST ANSWER

For the __imp_timeGetTime function, referenced from ...cilk_for... you need to link winmm.lib (see e.g. https://www.gamedev.net/topic/109957-unresolved-external-symbol-__imp__timegettime0/ or https://groups.google.com/forum/#!topic/v8-users/WsJYEcp_siY)