CUDAで行列計算をしたいのですがCUBLASが
CUDAで行列計算を行いたいのですが,エラーが出てしまいます.
原因がわからないので,わかる方いらっしゃいましたら教えてください.
変数の型の互換性の問題のようなのですが...
プログラムとエラー構文を添付しておきます.
環境はNVDIA Tesla K20,CUDA5.5,Ubuntu12.04です.
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <cublas.h>
#define N 1000
#define M 1500
#define K 500
int main(int args , char **argv)
{
double alpha = 3.0 , beta = 2.0;
double *hMatA , *hMatB , *hMatC;
double *dMatA , *dMatB , *dMatC;
int LDA = M , LDB = K ,LDC = M ;
int i;
cudaSetDevice(0);
cublasInit(); //CUBLASライブラリの初期化
cudaMallocHost((void**)&hMatA,sizeof(double)*M*K);
cudaMallocHost((void**)&hMatB,sizeof(double)*K*M);
cudaMallocHost((void**)&hMatC,sizeof(double)*M*N);
for(i=0;i<M*K;i++)
{
hMatA[i] = double(i+1);
}
for(i=0;i<K*N;i++)
{
hMatB[i] = double(i+1);
}
for(i=0;i<M*N;i++)
{
hMatC[i] = double(i+1);
}
cublasAlloc(M*K,sizeof(double),(void**)&dMatA); //CUBLASライブラリ用にデバイス・メモリを確保
cublasAlloc(K*N,sizeof(double),(void**)&dMatB);
cublasAlloc(M*N,sizeof(double),(void**)&dMatC);
/*
cublasSetMatrix(M*K,sizeof(double),hMatA,LDA,dMatA,M); //デバイス・メモリへ必要な部分を転送
cublasSetMatrix(K*N,sizeof(double),hMatB,LDB,dMatB,K);
cublasSetMatrix(M*N,sizeof(double),hMatC,LDC,dMatC,M);
*/
cublasSetMatrix(M*K,sizeof(double),hMatA,LDA,dMatA,M);
cublasSetMatrix(K*N,sizeof(double),hMatB,LDB,dMatB,K);
cublasSetMatrix(M*N,sizeof(double),hMatC,LDC,dMatC,M);
cublasDgemm('N','N',M,N,K,alpha,dMatA,M,dMatB,K,beta,dMatC,M); //DGEMMルーチンを呼び出す
cublasGetMatrix(M,N,sizeof(double),dMatC,M,hMatC,LDC);
cublasFree(dMatA);
cublasFree(dMatB);
cublasFree(dMatC);
cublasShutdown();
}
以下エラー構文
testinv.cu(44): error: argument of type "double *" is incompatible with parameter of type "int"
testinv.cu(44): error: argument of type "int" is incompatible with parameter of type "const void *"
testinv.cu(44): error: argument of type "double *" is incompatible with parameter of type "int"
testinv.cu(44): error: argument of type "int" is incompatible with parameter of type "void *"
testinv.cu(44): error: too few arguments in function call
testinv.cu(45): error: argument of type "double *" is incompatible with parameter of type "int"
testinv.cu(45): error: argument of type "int" is incompatible with parameter of type "const void *"
testinv.cu(45): error: argument of type "double *" is incompatible with parameter of type "int"
testinv.cu(45): error: argument of type "int" is incompatible with parameter of type "void *"
testinv.cu(45): error: too few arguments in function call
testinv.cu(46): error: argument of type "double *" is incompatible with parameter of type "int"
testinv.cu(46): error: argument of type "int" is incompatible with parameter of type "const void *"
testinv.cu(46): error: argument of type "double *" is incompatible with parameter of type "int"
testinv.cu(46): error: argument of type "int" is incompatible with parameter of type "void *"
testinv.cu(46): error: too few arguments in function call
15 errors detected in the compilation of "/tmp/tmpxft_00001df9_00000000-6_testinv.cpp1.ii".
お礼
わかりました どうもありがとうございます