Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <complex>
- #include <cublas_v2.h>
- using namespace std;
- int main () {
- const double alpha = 1.0;
- const double beta = 0.0;
- cublasHandle_t handle;
- cublasCreate(&handle);
- int xmax = 100;
- complex<double> u[xmax][xmax];
- complex<double>* d_u;
- complex<double>* d_uH;
- double arrSize = sizeof(complex<double>) * xmax * xmax;
- for(int i = 0;i<xmax;i++) {
- for(int j = 0; j<xmax;j++) {
- u[i][j] = complex<double> (1.0f,1.0f);
- }
- }
- u[49][51] = complex<double> (666.0f,666.0f);
- cudaMalloc(&d_u, arrSize);
- cudaMemcpy(d_u, u, arrSize, cudaMemcpyHostToDevice);
- cudaMalloc(&d_uH, arrSize);
- cublasZgeam(handle, CUBLAS_OP_T, CUBLAS_OP_N, xmax, xmax,
- &alpha, d_u, xmax,
- &beta, d_u, xmax,
- d_uH, xmax);
- cudaMemcpy(u, d_uH, arrSize, cudaMemcpyDeviceToHost);
- cout << u[51][49] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment