利用matlab和NVIDIA Nsight进行cufft CUDA代码分析

这篇博客介绍了如何利用MATLAB和NVIDIA Nsight工具来分析CUDA CUFFT代码。首先展示了CUFFT的CUDA C-MEX代码示例,然后详细说明了在Visual Studio中配置NVIDIA Nsight的过程,包括选择MATLAB作为调试应用、设置64位MATLAB执行文件、指定测试文件路径,并调整活动类型为CUDA应用程序。最后,演示了如何启动MATLAB,执行测试文件,以及如何通过Nsight捕获和分析kernel执行情况。
摘要由CSDN通过智能技术生成

分析之前肯定得有需要分析的代码,这里以fft为例:

1、fft的C-mex cuda代码如下所示:

#include "mex.h"
#include <cuda_runtime.h>
#include <cufft.h>


void mexFunction (int nlhs,mxArray *plhs[],int nrhs,mxArray *prhs[])
{
    if(nrhs != 1)
        mexErrMsgTxt("Invaid number of input arguments");
    if(! mxIsSingle(prhs[0])&&!mxIsSingle(prhs[1]))
        mexErrMsgTxt("input data type must be single");
    float* A=(float*)mxGetData(prhs[0]);
    int numARows = mxGetM(prhs[0]);
int numACols =mxGetN(prhs[0]);
    float *deviceA;
    
    cudaMalloc(&deviceA,sizeof(float)*numARows*numACols);
    cudaMemcpy(deviceA,A,numARows*numACols*sizeof(float),cudaMemcpyHostToDevice);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值