gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 05:43:00 28 4
gpt4 key购买 nike

我安装了 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com