yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
3fa0c21
master
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_single(void* inputC, void* output_cuFFT, int device_id, uint64_t* dims) 20{ 21 cudaSetDevice(device_id); 22 cufftHandle planC2C; 23 cufftComplex* dataC; 24 cudaMalloc((void**)&dataC, sizeof(cufftComplex) * dims[0] * dims[1] * dims[2]); 25 cudaMemcpy(dataC, inputC, sizeof(cufftComplex) * 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(&planC2C, dims[0], CUFFT_C2C, 1); 33 break; 34 case 2: 35 cufftPlan2d(&planC2C, dims[1], dims[0], CUFFT_C2C); 36 break; 37 case 3: 38 cufftPlan3d(&planC2C, dims[2], dims[1], dims[0], CUFFT_C2C); 39 break; 40 } 41 for (int i = 0; i < 1; i++) { 42 cufftExecC2C(planC2C, dataC, dataC, -1); 43 } 44 cudaDeviceSynchronize(); 45 cudaMemcpy(output_cuFFT, dataC, sizeof(cufftComplex) * dims[0] * dims[1] * dims[2], cudaMemcpyDeviceToHost); 46 cudaDeviceSynchronize(); 47 cufftDestroy(planC2C); 48 cudaFree(dataC); 49}