c++ - 通过安装 intel parallel X studio 使用 Cilk 库

标签 c++ visual-studio-2013 cilk intel-parallel-studio

我安装了 Intel studio 和 Visual studio 2013,我想编写一个使用线程的程序。我想通过 Intel 编译它,我做了这些步骤:

  1. 我创建一个空项目
  2. 我右键单击 cpp 源并选择使用 Intel 编译器,然后我选择对所选文件使用 intel c++,在选择所有配置后,我单击确定按钮。
  3. 然后我右键单击该项目,然后从我选择使用英特尔 C++ 的英特尔编译器项中。
  4. 为了确保我去属性(property)经理检查配置管理器,平台必须是 X64。更进一步,我在 c/c++ 中看到,优化 [Intel c++] 或通用 [Intel c++]。

所以我认为所有设置都正确完成。但是当我使用 Cilk/cilk.h 编写代码时出现这些错误

enter image description here

这是代码

#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;
}
// **********************************************************************

我应该说我尝试使用 _Cilk_for 而不是 cilk_for 但问题没有解决。

有人能告诉我这是什么问题吗?

最佳答案

对于 __imp_timeGetTime 函数,引用自 ...cilk_for... 您需要链接 winmm.lib(参见例如 https://www.gamedev.net/topic/109957-unresolved-external-symbol-__imp__timegettime0/https://groups.google.com/forum/#!topic/v8-users/WsJYEcp_siY)

关于c++ - 通过安装 intel parallel X studio 使用 Cilk 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30391904/

相关文章:

c++ - 去除空格 (C++)

c++ - 多次包含头文件导致编译时间变长?

c++ - 浏览器扩展与系统托盘应用

OpenCV 尝试加载未安装的 Cuda dll

visual-studio-2013 - 如何阻止 Visual Studio 2013 将映射源链接添加到 css 文件

c++ - 在tsan_libdispatch_mac.cc期间,使用cmake进行的LLVM构建失败。 “Error: conflicting types for …”

在GCC5.2.0中编译Cilk plus

c++ - 如果一个方法是从一个动态分配的对象调用的,它能以某种方式被内联吗(编译器优化)

c# - 如何阻止 512 mb ram 设备的应用程序?

c++ - 为什么它在 cilk 中给出段错误,我使用的是 ICC 编译器