几个cuda源代码示例

时间:2015-09-25 05:29:11
【文件属性】:
文件名称:几个cuda源代码示例
文件大小:9KB
文件格式:RAR
更新时间:2015-09-25 05:29:11
cuda gpu 几个cuda源代码示例 1.cuda矩阵例子.cu 2.实现矩阵的乘法.cu 3.... /*****************************************************************************************/ /核心代码部分,实现了矩阵的乘法运算/核心代码部分,实现了矩阵的乘法运算 /*****************************************************************************************/ / // Matrix multiplication kernel –thread specification __global__ void MatrixMulKernel(Matrix M, Matrix N, Matrix P) { // 2D Thread ID int tx = threadIdx.x; int ty = threadIdx.y; // Pvalue is used to store the element of the matrix // that is computed by the thread float Pvalue = 0; // 并行计算体现在次,多个thread并行进行 // 每个thread计算一行与一列的乘积 for (int k = 0; k < M.width; ++k) { float Melement = M.elements[ty * M.pitch + k]; float Nelement = Nd.elements[k * N.pitch + tx]; Pvalue += Melement * Nelement; } // Write the matrix to device memory; // each thread writes one element P.elements[ty * P.pitch + tx] = Pvalue; }
【文件预览】:
cuda code
----code()
--------cudaMallocAndMemcpy.cu(4KB)
--------reverseArry_singleblock.cu(4KB)
--------my_first_kernel.cu(4KB)
--------cuda矩阵例子.cu(2KB)
--------n_body.cu(2KB)
--------实现矩阵的乘法.cu(5KB)

网友评论

  • 没下成功 评论一下继续下
  • 资源还不错了,网上也挺难找更好的了
  • 试了一下,搞了两天才把环境配起来,不错,谢谢楼主。
  • 不错的学习资料
  • 初学cuda,拿来参考学习。
  • 例子不错,挺有帮助的。
  • 参加了中科院的培训班,和那里面的考核题目类似,非常好难得的资源,学习cuda并行计算专用,多谢共享。
  • 不错的例子,帮助学习cuda