英特尔 MKL 函数错误 (C++)

发布于 2025-01-02 17:42:47 字数 2178 浏览 1 评论 0原文

我试图测试 Intel 的速度 MKL,但它给出了警告和错误,

ipo : warning #11021: unresolved @cblas_sdot@20
1>          Referenced in ipo_36165obj.obj
1>ipo : error #11023: Not all components required for linking are present on command line

cpp 文件:

#pragma once

#include <iostream>
#include <mkl_cblas.h>
#include <time.h>
#include <iomanip>

int main () {

float a[3], b[3], c;

a[0] = 1.f;
a[1] = 2.f;
a[2] = 3.f;

b[0] = 4.f;
b[1] = 5.f;
b[2] = 6.f;

int num = 1e5;
bool key = 0;

clock_t sTime = clock();

if (key) {

    for (int i=0; i<num; ++i) {

        c = cblas_sdot(3,a,1,b,1);
    }
}
else {

    for (int i=0; i<num; ++i) {

        c = a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
    }
}

clock_t elap = clock() - sTime;
float eTime = elap / ((float) CLOCKS_PER_SEC);

if (eTime > 60) {eTime /= 60; std::cout << ">> elapsed time : " << std::fixed << std::setprecision(1) << eTime << " min" << std::endl;}
else {std::cout << ">> elapsed time : " << std::fixed << std::setprecision(5) << eTime << " sec" << std::endl;} 

std::cin.ignore();  

return 0;
}

编辑:

链接器的命令行:

/OUT:"C:\Users \Orxan\videos\documents\visual studio 2010\Projects\arrTut\Release\arrTut.exe" /NOLOGO "kernel32.lib" "user32.lib" “gdi32.lib”“winspool.lib”“comdlg32.lib”“advapi32.lib”“shell32.lib”“ole32.lib”“oleaut32.lib”“uuid.lib”“odbc32.lib”“odbccp32.lib” /MANIFEST /ManifestFile:"Release\arrTut.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Orxan\videos\documents\visual studio 2010\Projects\arrTut\Release\arrTut.pdb" /OPT:REF /OPT:ICF /PGD:"C:\Users\Orxan\videos\documents\visual studio 2010\Projects\arrTut\Release\arrTut.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86

编译器命令行:

/Zi /nologo /W3 /O2 /Ob2 /Oi /Ot /Oy /Qipo /GA /Qparallel /D "_MBCS" /EHsc /GS /Gy /fp:fast /Zc:wchar_t /Zc:forScope /Fp"Release\arrTut.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gr

I was trying to test the speed MKL of Intel but it gives a warning and an error as,

ipo : warning #11021: unresolved @cblas_sdot@20
1>          Referenced in ipo_36165obj.obj
1>ipo : error #11023: Not all components required for linking are present on command line

The cpp file:

#pragma once

#include <iostream>
#include <mkl_cblas.h>
#include <time.h>
#include <iomanip>

int main () {

float a[3], b[3], c;

a[0] = 1.f;
a[1] = 2.f;
a[2] = 3.f;

b[0] = 4.f;
b[1] = 5.f;
b[2] = 6.f;

int num = 1e5;
bool key = 0;

clock_t sTime = clock();

if (key) {

    for (int i=0; i<num; ++i) {

        c = cblas_sdot(3,a,1,b,1);
    }
}
else {

    for (int i=0; i<num; ++i) {

        c = a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
    }
}

clock_t elap = clock() - sTime;
float eTime = elap / ((float) CLOCKS_PER_SEC);

if (eTime > 60) {eTime /= 60; std::cout << ">> elapsed time : " << std::fixed << std::setprecision(1) << eTime << " min" << std::endl;}
else {std::cout << ">> elapsed time : " << std::fixed << std::setprecision(5) << eTime << " sec" << std::endl;} 

std::cin.ignore();  

return 0;
}

EDIT:

The command line for linker:

/OUT:"C:\Users\Orxan\videos\documents\visual studio 2010\Projects\arrTut\Release\arrTut.exe" /NOLOGO "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Release\arrTut.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Orxan\videos\documents\visual studio 2010\Projects\arrTut\Release\arrTut.pdb" /OPT:REF /OPT:ICF /PGD:"C:\Users\Orxan\videos\documents\visual studio 2010\Projects\arrTut\Release\arrTut.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86

The compiler command line:

/Zi /nologo /W3 /O2 /Ob2 /Oi /Ot /Oy /Qipo /GA /Qparallel /D "_MBCS" /EHsc /GS /Gy /fp:fast /Zc:wchar_t /Zc:forScope /Fp"Release\arrTut.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gr

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文