有没有办法在CUDA内核中运行Windows API函数? 我最近想在C++中创建内存扫描器,我想用我的CUDA内核来实现。但每次我想编译代码时,都会得到一个错误MSB3721
那么有没有办法从CUDA内核调用Windows API函数呢?您不能从CUDA内核调用Windows API。但也许,您可以使用pinnedmemory访问cpu端内存,并使用cuda内核中的一些关键字对其进行扫描。 为此,您需要不断地从cpu端输入新的内存区域,同时检查gpu内核是否找到了什么 代码可以是这样的有没有办法在CUDA内核中运行Windows API函数? 我最近想在C++中创建内存扫描器,我想用我的CUDA内核来实现。但每次我想编译代码时,都会得到一个错误MSB3721,windows,api,cuda,Windows,Api,Cuda,那么有没有办法从CUDA内核调用Windows API函数呢?您不能从CUDA内核调用Windows API。但也许,您可以使用pinnedmemory访问cpu端内存,并使用cuda内核中的一些关键字对其进行扫描。 为此,您需要不断地从cpu端输入新的内存区域,同时检查gpu内核是否找到了什么 代码可以是这样的 int main() { Int ScannerID = 0; bool result=false; byte *h_aPin
int main()
{
Int ScannerID = 0;
bool result=false;
byte *h_aPinned;
int bytes=1000; //batch size for mem copying
// allocate and initialize
cudaMallocHost((void**)&h_aPinned, bytes,cudaHostAllocDefault);
//do stuff and fill h_aPinned with ram memory
//constantly check kernel for the results
do
kernel<<<x, y>>>(h_aPinned, result, ScannerID); //(decide x & y for your conditions)
if (result==false)
{
//copy another batch of memory just by filling h_aPinned with it.
}
while (result = true)
return 0;
}
一句话——不。以PCI-e速度运行内存扫描有什么意义?谢谢,我知道你会将ram内存加载到cuda内核中,然后进一步处理内存块?@Talonmes我想这会使我的扫描过程更快。你有最喜欢的扫描方法吗?(非cuda).绝对不会更快。整个想法都是荒谬的。用笔和纸画30秒,计算有效带宽和延迟,并证明这毫无意义您的
cudamalochost
语法是错误的。在我看来,结果总是错误的。
_global__ void kernel(byte* batchmem, bool* result, int* ID)
{
ID = threadIdx.x; //for which part of memory return true and calculate batch start point
//do search with batchmem
//you can divide search areas on threads
}