yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
9a96811
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//ROCM parts 15#include "hip/hip_runtime.h" 16#include <hipfft/hipfft.h> 17 18void launch_precision_rocFFT_single ( void * inputC , void * output_rocFFT , int device_id , uint64_t * dims ) 19{ 20hipSetDevice ( device_id ) ; 21hipfftHandle planC2C ; 22hipfftComplex * dataC ; 23hipMalloc (( void ** ) & dataC , sizeof ( hipfftComplex ) * dims [ 0 ] * dims [ 1 ] * dims [ 2 ]) ; 24hipMemcpy ( dataC , inputC , sizeof ( hipfftComplex ) * dims [ 0 ] * dims [ 1 ] * dims [ 2 ] , hipMemcpyHostToDevice ) ; 25if ( hipGetLastError () != hipSuccess ) { 26fprintf ( stderr , "ROCM error: Failed to allocate \n " ) ; 27return ; 28} 29switch ( dims [ 4 ]) { 30case 1 : 31hipfftPlan1d ( & planC2C , dims [ 0 ] , HIPFFT_C2C , 1 ) ; 32break ; 33case 2 : 34hipfftPlan2d ( & planC2C , dims [ 1 ] , dims [ 0 ] , HIPFFT_C2C ) ; 35break ; 36case 3 : 37hipfftPlan3d ( & planC2C , dims [ 2 ] , dims [ 1 ] , dims [ 0 ] , HIPFFT_C2C ) ; 38break ; 39} 40for ( int i = 0 ; i < 1 ; i ++ ) { 41hipfftExecC2C ( planC2C , dataC , dataC , - 1 ) ; 42} 43hipDeviceSynchronize () ; 44hipMemcpy ( output_rocFFT , dataC , sizeof ( hipfftComplex ) * dims [ 0 ] * dims [ 1 ] * dims [ 2 ] , hipMemcpyDeviceToHost ) ; 45hipDeviceSynchronize () ; 46hipfftDestroy ( planC2C ) ; 47hipFree ( dataC ) ; 48}