gpt4 book ai didi

c++ - 使用 CUDA 和 Matlab 时如何将矩阵作为参数

转载 作者:行者123 更新时间:2023-11-28 07:05:27 24 4
gpt4 key购买 nike

我正在尝试弄清楚如何将矩阵从 Matlab 传递到 C++ CUDA 文件 (*.ptx)。我想在每个线程中以不同方式处理矩阵!我绝对不想在不同的线程中拆分矩阵!我希望每个线程都有相同的矩阵!

Matlab and CUDA (C++)

我试过类似的方法:

_global_ void radialAverage(int* image[][]) {
...
}

但是没有用。我收到以下错误:

kernel.cu(8): error: an array may not have elements of this type
1 error detected in the compilation of "C:/Users/ADMINI~1/AppData/Loca/Temp/tmpxft_00000c44_00000000-8_kernel.cpp1.ii".

你能想出什么办法来做到这一点吗?或者有可能吗?

顺便说一句:我没有使用任何 C++ 库,只有 CUDA-Api。

最佳答案

定义内核以从 Matlab 传递矩阵的正确方法在您在问题中链接到的页面上清楚地显示(多次)。

总而言之,像这样定义内核(Matlab gpuArray 作为设备指针自动传递给内核):

__global__ void radialAverage(int* image) {
...
}

使用工具箱中的 CUDAKernel 检索内核后,从 Matlab 矩阵创建一个整数 gpuArray,并将其传递给内核函数。

关于c++ - 使用 CUDA 和 Matlab 时如何将矩阵作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21827030/

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