yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
9640836
v1.2.31
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//ROCM parts 15#include "hip/hip_runtime.h" 16#include <hipfft.h> 17 18void launch_precision_rocFFT_r2c ( void * inputC , void * output_rocFFT , int device_id , uint64_t * dims ) 19{ 20hipSetDevice ( device_id ) ; 21hipfftHandle planR2C ; 22hipfftReal * dataR ; 23hipfftComplex * dataC ; 24hipMalloc (( void ** ) & dataR , sizeof ( hipfftComplex ) * ( dims [ 0 ] / 2 + 1 ) * dims [ 1 ] * dims [ 2 ]) ; 25hipMalloc (( void ** ) & dataC , sizeof ( hipfftComplex ) * ( dims [ 0 ] / 2 + 1 ) * dims [ 1 ] * dims [ 2 ]) ; 26hipMemcpy ( dataR , inputC , sizeof ( hipfftReal ) * dims [ 0 ] * dims [ 1 ] * dims [ 2 ] , hipMemcpyHostToDevice ) ; 27if ( hipGetLastError () != hipSuccess ) { 28fprintf ( stderr , "ROCM error: Failed to allocate \n " ) ; 29return ; 30} 31switch ( dims [ 3 ]) { 32case 1 : 33hipfftPlan1d ( & planR2C , dims [ 0 ] , HIPFFT_R2C , 1 ) ; 34break ; 35case 2 : 36hipfftPlan2d ( & planR2C , dims [ 1 ] , dims [ 0 ] , HIPFFT_R2C ) ; 37break ; 38case 3 : 39hipfftPlan3d ( & planR2C , dims [ 2 ] , dims [ 1 ] , dims [ 0 ] , HIPFFT_R2C ) ; 40break ; 41} 42for ( int i = 0 ; i < 1 ; i ++ ) { 43hipfftExecR2C ( planR2C , dataR , dataC ) ; 44} 45hipDeviceSynchronize () ; 46hipfftDestroy ( planR2C ) ; 47switch ( dims [ 3 ]) { 48case 1 : 49hipfftPlan1d ( & planR2C , dims [ 0 ] , HIPFFT_C2R , 1 ) ; 50break ; 51case 2 : 52hipfftPlan2d ( & planR2C , dims [ 1 ] , dims [ 0 ] , HIPFFT_C2R ) ; 53break ; 54case 3 : 55hipfftPlan3d ( & planR2C , dims [ 2 ] , dims [ 1 ] , dims [ 0 ] , HIPFFT_C2R ) ; 56break ; 57} 58for ( int i = 0 ; i < 1 ; i ++ ) { 59hipfftExecC2R ( planR2C , dataC , dataR ) ; 60} 61hipDeviceSynchronize () ; 62hipMemcpy ( output_rocFFT , dataR , sizeof ( float ) * ( dims [ 0 ] ) * dims [ 1 ] * dims [ 2 ] , hipMemcpyDeviceToHost ) ; 63hipDeviceSynchronize () ; 64hipfftDestroy ( planR2C ) ; 65hipFree ( dataR ) ; 66hipFree ( dataC ) ; 67}