yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
3fa0c21
v1.3.4
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{ 21cudaSetDevice ( device_id ) ; 22cufftHandle planC2C ; 23cufftComplex * dataC ; 24cudaMalloc (( void ** ) & dataC , sizeof ( cufftComplex ) * dims [ 0 ] * dims [ 1 ] * dims [ 2 ]) ; 25cudaMemcpy ( dataC , inputC , sizeof ( cufftComplex ) * dims [ 0 ] * dims [ 1 ] * dims [ 2 ] , cudaMemcpyHostToDevice ) ; 26if ( cudaGetLastError () != cudaSuccess ) { 27fprintf ( stderr , "Cuda error: Failed to allocate \n " ) ; 28return ; 29} 30switch ( dims [ 4 ]) { 31case 1 : 32cufftPlan1d ( & planC2C , dims [ 0 ] , CUFFT_C2C , 1 ) ; 33break ; 34case 2 : 35cufftPlan2d ( & planC2C , dims [ 1 ] , dims [ 0 ] , CUFFT_C2C ) ; 36break ; 37case 3 : 38cufftPlan3d ( & planC2C , dims [ 2 ] , dims [ 1 ] , dims [ 0 ] , CUFFT_C2C ) ; 39break ; 40} 41for ( int i = 0 ; i < 1 ; i ++ ) { 42cufftExecC2C ( planC2C , dataC , dataC , - 1 ) ; 43} 44cudaDeviceSynchronize () ; 45cudaMemcpy ( output_cuFFT , dataC , sizeof ( cufftComplex ) * dims [ 0 ] * dims [ 1 ] * dims [ 2 ] , cudaMemcpyDeviceToHost ) ; 46cudaDeviceSynchronize () ; 47cufftDestroy ( planC2C ) ; 48cudaFree ( dataC ) ; 49}