yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
3fa0c21
develop
1//general parts 2#include <stdio.h> 3#include <vector> 4#include <memory> 5#include <string.h> 6#include <chrono> 7#include <thread> 8#include <iostream> 9#ifndef __STDC_FORMAT_MACROS 10#define __STDC_FORMAT_MACROS 11#endif 12#include <inttypes.h> 13 14//CUDA parts 15#include "cuda_runtime.h" 16#include "device_launch_parameters.h" 17#include <cufft.h> 18 19void launch_precision_cuFFT_double(void* inputC, void* output_cuFFT, int device_id, uint64_t* dims) 20{ 21 cudaSetDevice(device_id); 22 cufftHandle planZ2Z; 23 cufftDoubleComplex* dataC; 24 cudaMalloc((void**)&dataC, sizeof(cufftDoubleComplex) * dims[0] * dims[1] * dims[2]); 25 cudaMemcpy(dataC, inputC, sizeof(cufftDoubleComplex) * dims[0] * dims[1] * dims[2], cudaMemcpyHostToDevice); 26 if (cudaGetLastError() != cudaSuccess) { 27 fprintf(stderr, "Cuda error: Failed to allocate\n"); 28 return; 29 } 30 switch (dims[4]) { 31 case 1: 32 cufftPlan1d(&planZ2Z, dims[0], CUFFT_Z2Z, 1); 33 break; 34 case 2: 35 cufftPlan2d(&planZ2Z, dims[1], dims[0], CUFFT_Z2Z); 36 break; 37 case 3: 38 cufftPlan3d(&planZ2Z, dims[2], dims[1], dims[0], CUFFT_Z2Z); 39 break; 40 } 41 for (int i = 0; i < 1; i++) { 42 cufftExecZ2Z(planZ2Z, dataC, dataC, -1); 43 } 44 cudaDeviceSynchronize(); 45 cudaMemcpy(output_cuFFT, dataC, sizeof(cufftDoubleComplex) * dims[0] * dims[1] * dims[2], cudaMemcpyDeviceToHost); 46 cudaDeviceSynchronize(); 47 cufftDestroy(planZ2Z); 48 cudaFree(dataC); 49}