gpt4 book ai didi

c++ - 如何同时使用 parallel_for_each 函数和 __declspec(dllexport) 属性

转载 作者:太空宇宙 更新时间:2023-11-04 11:46:39 26 4
gpt4 key购买 nike

最近我写了一个这样的函数:

#include "amp.h"
#define DLLExport __declspec(dllexport)
using namespace concurrency;

namespace dll
{
class SomeMethods
{
public:
static DLLExport double CalcConvolution(double* mask, double* map, int size)
{
array_view<const double, 1> avMask(size, mask);
array_view<double, 1> avOMap(size, map);
array_view<double, 1> avCache(size, new double[size]);
avCache.discard_data();
parallel_for_each(
avCache.extent,
[=](index<1> idx) restrict(amp)
{
avCache[idx] = avMask[idx] * avOMap[idx];
}
);
avCache.synchronize();
double sum = 0;
auto cache = avCache.data();
for (int i = 0; i < size; i++)
sum += cache[i];
return sum;
}
};
}

Visual Studio 报告了以下错误:

error C1451: Failed to generate debug information when compiling the call graph for the concurrency::parallel_for_each

一旦我删除了 DLLEXPORT 修饰符,错误就消失了,但我无法再将此函数导出到我的其他程序。

我该如何解决这个问题?

最佳答案

我们观察到当 TMP 环境变量值包含非 ASCII 字符时会报告错误 C1451。临时解决方法是将用户环境变量设置为例如C:\tmp.

关于c++ - 如何同时使用 parallel_for_each 函数和 __declspec(dllexport) 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19618319/

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