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_double (void * inputC ,void * output_rocFFT ,int device_id ,uint64_t * dims ) 19{ 20hipSetDevice (device_id ); 21hipfftHandle planZ2Z ; 22hipfftDoubleComplex * dataC ; 23hipMalloc ((void ** )& dataC ,sizeof (hipfftDoubleComplex )* dims [0 ]* dims [1 ]* dims [2 ]); 24hipMemcpy (dataC ,inputC ,sizeof (hipfftDoubleComplex )* 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 (& planZ2Z ,dims [0 ],HIPFFT_Z2Z ,1 ); 32break ; 33case 2 : 34hipfftPlan2d (& planZ2Z ,dims [1 ],dims [0 ],HIPFFT_Z2Z ); 35break ; 36case 3 : 37hipfftPlan3d (& planZ2Z ,dims [2 ],dims [1 ],dims [0 ],HIPFFT_Z2Z ); 38break ; 39 } 40for (int i = 0 ;i < 1 ;i ++ ) { 41hipfftExecZ2Z (planZ2Z ,dataC ,dataC ,-1 ); 42 } 43hipDeviceSynchronize (); 44hipMemcpy (output_rocFFT ,dataC ,sizeof (hipfftDoubleComplex )* dims [0 ]* dims [1 ]* dims [2 ],hipMemcpyDeviceToHost ); 45hipDeviceSynchronize (); 46hipfftDestroy (planZ2Z ); 47hipFree (dataC ); 48}