yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
a7a5397
v1.3.1
1#include < vector > 2#include <memory> 3#include <string.h> 4#include <chrono> 5#include <thread> 6#include <iostream> 7#include <algorithm> 8#define __STDC_FORMAT_MACROS 9#include <inttypes.h> 10#if ( VKFFT_BACKEND == 0 ) 11#include "vulkan/vulkan.h" 12#include "glslang_c_interface.h" 13#elif ( VKFFT_BACKEND == 1 ) 14#include < cuda . h > 15#include <cuda_runtime.h> 16#include <nvrtc.h> 17#include <cuda_runtime_api.h> 18#include <cuComplex.h> 19#elif ( VKFFT_BACKEND == 2 ) 20#ifndef __HIP_PLATFORM_HCC__ 21#define __HIP_PLATFORM_HCC__ 22#endif 23#include <hip/hip_runtime.h> 24#include <hip/hiprtc.h> 25#include <hip/hip_runtime_api.h> 26#include <hip/hip_complex.h> 27#elif ( VKFFT_BACKEND == 3 ) 28#ifndef CL_USE_DEPRECATED_OPENCL_1_2_APIS 29#define CL_USE_DEPRECATED_OPENCL_1_2_APIS 30#endif 31#ifdef __APPLE__ 32#include <OpenCL/opencl.h> 33#else 34#include <CL/cl.h> 35#endif 36#elif ( VKFFT_BACKEND == 4 ) 37#include < ze_api . h > 38#elif ( VKFFT_BACKEND == 5 ) 39#ifndef NS_PRIVATE_IMPLEMENTATION 40#define NS_PRIVATE_IMPLEMENTATION 41#endif 42#ifndef CA_PRIVATE_IMPLEMENTATION 43#define CA_PRIVATE_IMPLEMENTATION 44#endif 45#ifndef MTL_PRIVATE_IMPLEMENTATION 46#define MTL_PRIVATE_IMPLEMENTATION 47#endif 48#include "Foundation/Foundation.hpp" 49#include "QuartzCore/QuartzCore.hpp" 50#include "Metal/Metal.hpp" 51#endif 52#include "vkFFT.h" 53#include "utils_VkFFT.h" 54#include "half.hpp" 55#include "user_benchmark_VkFFT.h" 56#include "sample_0_benchmark_VkFFT_single.h" 57#include "sample_1_benchmark_VkFFT_double.h" 58#include "sample_2_benchmark_VkFFT_half.h" 59#include "sample_3_benchmark_VkFFT_single_3d.h" 60#include "sample_4_benchmark_VkFFT_single_3d_zeropadding.h" 61#include "sample_5_benchmark_VkFFT_single_disableReorderFourStep.h" 62#include "sample_6_benchmark_VkFFT_single_r2c.h" 63#include "sample_7_benchmark_VkFFT_single_Bluestein.h" 64#include "sample_8_benchmark_VkFFT_double_Bluestein.h" 65#include "sample_10_benchmark_VkFFT_single_multipleBuffers.h" 66#ifdef USE_FFTW 67#include "sample_11_precision_VkFFT_single.h" 68#include "sample_12_precision_VkFFT_double.h" 69#include "sample_13_precision_VkFFT_half.h" 70#include "sample_14_precision_VkFFT_single_nonPow2.h" 71#include "sample_15_precision_VkFFT_single_r2c.h" 72#include "sample_16_precision_VkFFT_single_dct.h" 73#include "sample_17_precision_VkFFT_double_dct.h" 74#include "sample_18_precision_VkFFT_double_nonPow2.h" 75#endif 76#include "sample_50_convolution_VkFFT_single_1d_matrix.h" 77#include "sample_51_convolution_VkFFT_single_3d_matrix_zeropadding_r2c.h" 78#include "sample_52_convolution_VkFFT_single_2d_batched_r2c.h" 79 80#include "sample_100_benchmark_VkFFT_single_nd_dct.h" 81#include "sample_101_benchmark_VkFFT_double_nd_dct.h" 82#include "sample_1000_VkFFT_single_2_4096.h" 83#include "sample_1001_benchmark_VkFFT_double_2_4096.h" 84#include "sample_1003_benchmark_VkFFT_single_3d_2_512.h" 85 86#ifdef USE_cuFFT 87#include "user_benchmark_cuFFT.h" 88#include "sample_0_benchmark_cuFFT_single.h" 89#include "sample_1_benchmark_cuFFT_double.h" 90#include "sample_2_benchmark_cuFFT_half.h" 91#include "sample_3_benchmark_cuFFT_single_3d.h" 92#include "sample_6_benchmark_cuFFT_single_r2c.h" 93#include "sample_7_benchmark_cuFFT_single_Bluestein.h" 94#include "sample_8_benchmark_cuFFT_double_Bluestein.h" 95#include "sample_1000_benchmark_cuFFT_single_2_4096.h" 96#include "sample_1001_benchmark_cuFFT_double_2_4096.h" 97#include "sample_1003_benchmark_cuFFT_single_3d_2_512.h" 98#endif 99#ifdef USE_rocFFT 100#include "user_benchmark_rocFFT.h" 101#include "sample_0_benchmark_rocFFT_single.h" 102#include "sample_1_benchmark_rocFFT_double.h" 103#include "sample_3_benchmark_rocFFT_single_3d.h" 104#include "sample_6_benchmark_rocFFT_single_r2c.h" 105#include "sample_7_benchmark_rocFFT_single_Bluestein.h" 106#include "sample_8_benchmark_rocFFT_double_Bluestein.h" 107#include "sample_1000_benchmark_rocFFT_single_2_4096.h" 108#include "sample_1001_benchmark_rocFFT_double_2_4096.h" 109#include "sample_1003_benchmark_rocFFT_single_3d_2_512.h" 110#endif 111#ifdef USE_FFTW 112#include "fftw3.h" 113#endif 114 115VkFFTResult launchVkFFT ( VkGPU * vkGPU , uint64_t sample_id , bool file_output , FILE * output , VkFFTUserSystemParameters * userParams ) { 116//Sample Vulkan project GPU initialization. 117VkFFTResult resFFT = VKFFT_SUCCESS ; 118 119#if ( VKFFT_BACKEND == 0 ) 120VkResult res = VK_SUCCESS ; 121//create instance - a connection between the application and the Vulkan library 122res = createInstance ( vkGPU , sample_id ) ; 123if ( res != 0 ) { 124//printf("Instance creation failed, error code: %" PRIu64 "\n", res); 125return VKFFT_ERROR_FAILED_TO_CREATE_INSTANCE ; 126} 127//set up the debugging messenger 128res = setupDebugMessenger ( vkGPU ) ; 129if ( res != 0 ) { 130//printf("Debug messenger creation failed, error code: %" PRIu64 "\n", res); 131return VKFFT_ERROR_FAILED_TO_SETUP_DEBUG_MESSENGER ; 132} 133//check if there are GPUs that support Vulkan and select one 134res = findPhysicalDevice ( vkGPU ) ; 135if ( res != 0 ) { 136//printf("Physical device not found, error code: %" PRIu64 "\n", res); 137return VKFFT_ERROR_FAILED_TO_FIND_PHYSICAL_DEVICE ; 138} 139//create logical device representation 140res = createDevice ( vkGPU , sample_id ) ; 141if ( res != 0 ) { 142//printf("Device creation failed, error code: %" PRIu64 "\n", res); 143return VKFFT_ERROR_FAILED_TO_CREATE_DEVICE ; 144} 145//create fence for synchronization 146res = createFence ( vkGPU ) ; 147if ( res != 0 ) { 148//printf("Fence creation failed, error code: %" PRIu64 "\n", res); 149return VKFFT_ERROR_FAILED_TO_CREATE_FENCE ; 150} 151//create a place, command buffer memory is allocated from 152res = createCommandPool ( vkGPU ) ; 153if ( res != 0 ) { 154//printf("Fence creation failed, error code: %" PRIu64 "\n", res); 155return VKFFT_ERROR_FAILED_TO_CREATE_COMMAND_POOL ; 156} 157vkGetPhysicalDeviceProperties ( vkGPU -> physicalDevice , & vkGPU -> physicalDeviceProperties ) ; 158vkGetPhysicalDeviceMemoryProperties ( vkGPU -> physicalDevice , & vkGPU -> physicalDeviceMemoryProperties ) ; 159 160glslang_initialize_process () ; //compiler can be initialized before VkFFT 161#elif ( VKFFT_BACKEND == 1 ) 162CUresult res = CUDA_SUCCESS ; 163cudaError_t res2 = cudaSuccess ; 164res = cuInit ( 0 ) ; 165if ( res != CUDA_SUCCESS ) return VKFFT_ERROR_FAILED_TO_INITIALIZE ; 166res2 = cudaSetDevice (( int ) vkGPU -> device_id ) ; 167if ( res2 != cudaSuccess ) return VKFFT_ERROR_FAILED_TO_SET_DEVICE_ID ; 168res = cuDeviceGet ( & vkGPU -> device , ( int ) vkGPU -> device_id ) ; 169if ( res != CUDA_SUCCESS ) return VKFFT_ERROR_FAILED_TO_GET_DEVICE ; 170res = cuCtxCreate ( & vkGPU -> context , 0 , ( int ) vkGPU -> device ) ; 171if ( res != CUDA_SUCCESS ) return VKFFT_ERROR_FAILED_TO_CREATE_CONTEXT ; 172#elif ( VKFFT_BACKEND == 2 ) 173hipError_t res = hipSuccess ; 174res = hipInit ( 0 ) ; 175if ( res != hipSuccess ) return VKFFT_ERROR_FAILED_TO_INITIALIZE ; 176res = hipSetDevice (( int ) vkGPU -> device_id ) ; 177if ( res != hipSuccess ) return VKFFT_ERROR_FAILED_TO_SET_DEVICE_ID ; 178res = hipDeviceGet ( & vkGPU -> device , ( int ) vkGPU -> device_id ) ; 179if ( res != hipSuccess ) return VKFFT_ERROR_FAILED_TO_GET_DEVICE ; 180res = hipCtxCreate ( & vkGPU -> context , 0 , ( int ) vkGPU -> device ) ; 181if ( res != hipSuccess ) return VKFFT_ERROR_FAILED_TO_CREATE_CONTEXT ; 182#elif ( VKFFT_BACKEND == 3 ) 183cl_int res = CL_SUCCESS ; 184cl_uint numPlatforms ; 185res = clGetPlatformIDs ( 0 , 0 , & numPlatforms ) ; 186if ( res != CL_SUCCESS ) return VKFFT_ERROR_FAILED_TO_INITIALIZE ; 187cl_platform_id * platforms = ( cl_platform_id * ) malloc ( sizeof ( cl_platform_id ) * numPlatforms ) ; 188if ( ! platforms ) return VKFFT_ERROR_MALLOC_FAILED ; 189res = clGetPlatformIDs ( numPlatforms , platforms , 0 ) ; 190if ( res != CL_SUCCESS ) return VKFFT_ERROR_FAILED_TO_INITIALIZE ; 191uint64_t k = 0 ; 192for ( uint64_t j = 0 ; j < numPlatforms ; j ++ ) { 193cl_uint numDevices ; 194res = clGetDeviceIDs ( platforms [ j ] , CL_DEVICE_TYPE_ALL , 0 , 0 , & numDevices ) ; 195cl_device_id * deviceList = ( cl_device_id * ) malloc ( sizeof ( cl_device_id ) * numDevices ) ; 196if ( ! deviceList ) return VKFFT_ERROR_MALLOC_FAILED ; 197res = clGetDeviceIDs ( platforms [ j ] , CL_DEVICE_TYPE_ALL , numDevices , deviceList , 0 ) ; 198if ( res != CL_SUCCESS ) return VKFFT_ERROR_FAILED_TO_GET_DEVICE ; 199for ( uint64_t i = 0 ; i < numDevices ; i ++ ) { 200if ( k == vkGPU -> device_id ) { 201vkGPU -> platform = platforms [ j ] ; 202vkGPU -> device = deviceList [ i ] ; 203vkGPU -> context = clCreateContext ( NULL , 1 , & vkGPU -> device , NULL , NULL , & res ) ; 204if ( res != CL_SUCCESS ) return VKFFT_ERROR_FAILED_TO_CREATE_CONTEXT ; 205cl_command_queue commandQueue = clCreateCommandQueue ( vkGPU -> context , vkGPU -> device , 0 , & res ) ; 206if ( res != CL_SUCCESS ) return VKFFT_ERROR_FAILED_TO_CREATE_COMMAND_QUEUE ; 207vkGPU -> commandQueue = commandQueue ; 208i = numDevices ; 209j = numPlatforms ; 210} 211else { 212k ++ ; 213} 214} 215free ( deviceList ) ; 216} 217free ( platforms ) ; 218#elif ( VKFFT_BACKEND == 4 ) 219ze_result_t res = ZE_RESULT_SUCCESS ; 220res = zeInit ( 0 ) ; 221if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_INITIALIZE ; 222uint32_t numDrivers = 0 ; 223res = zeDriverGet ( & numDrivers , 0 ) ; 224if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_INITIALIZE ; 225ze_driver_handle_t * drivers = ( ze_driver_handle_t * ) malloc ( numDrivers * sizeof ( ze_driver_handle_t )) ; 226if ( ! drivers ) return VKFFT_ERROR_MALLOC_FAILED ; 227res = zeDriverGet ( & numDrivers , drivers ) ; 228if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_INITIALIZE ; 229uint64_t k = 0 ; 230for ( uint64_t j = 0 ; j < numDrivers ; j ++ ) { 231uint32_t numDevices = 0 ; 232res = zeDeviceGet ( drivers [ j ] , & numDevices , nullptr ) ; 233if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_GET_DEVICE ; 234ze_device_handle_t * deviceList = ( ze_device_handle_t * ) malloc ( numDevices * sizeof ( ze_device_handle_t )) ; 235if ( ! deviceList ) return VKFFT_ERROR_MALLOC_FAILED ; 236res = zeDeviceGet ( drivers [ j ] , & numDevices , deviceList ) ; 237if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_GET_DEVICE ; 238for ( uint64_t i = 0 ; i < numDevices ; i ++ ) { 239if ( k == vkGPU -> device_id ) { 240vkGPU -> driver = drivers [ j ] ; 241vkGPU -> device = deviceList [ i ] ; 242ze_context_desc_t contextDescription = {} ; 243contextDescription . stype = ZE_STRUCTURE_TYPE_CONTEXT_DESC ; 244res = zeContextCreate ( vkGPU -> driver , & contextDescription , & vkGPU -> context ) ; 245if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_CREATE_CONTEXT ; 246 247uint32_t queueGroupCount = 0 ; 248res = zeDeviceGetCommandQueueGroupProperties ( vkGPU -> device , & queueGroupCount , 0 ) ; 249if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_CREATE_COMMAND_QUEUE ; 250 251ze_command_queue_group_properties_t * cmdqueueGroupProperties = ( ze_command_queue_group_properties_t * ) malloc ( queueGroupCount * sizeof ( ze_command_queue_group_properties_t )) ; 252if ( ! cmdqueueGroupProperties ) return VKFFT_ERROR_MALLOC_FAILED ; 253res = zeDeviceGetCommandQueueGroupProperties ( vkGPU -> device , & queueGroupCount , cmdqueueGroupProperties ) ; 254if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_CREATE_COMMAND_QUEUE ; 255 256uint32_t commandQueueID = - 1 ; 257for ( uint32_t i = 0 ; i < queueGroupCount ; ++ i ) { 258if (( cmdqueueGroupProperties [ i ] . flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE ) && ( cmdqueueGroupProperties [ i ] . flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY )) { 259commandQueueID = i ; 260break ; 261} 262} 263if ( commandQueueID == - 1 ) return VKFFT_ERROR_FAILED_TO_CREATE_COMMAND_QUEUE ; 264vkGPU -> commandQueueID = commandQueueID ; 265ze_command_queue_desc_t commandQueueDescription = {} ; 266commandQueueDescription . stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC ; 267commandQueueDescription . ordinal = commandQueueID ; 268commandQueueDescription . priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL ; 269commandQueueDescription . mode = ZE_COMMAND_QUEUE_MODE_DEFAULT ; 270res = zeCommandQueueCreate ( vkGPU -> context , vkGPU -> device , & commandQueueDescription , & vkGPU -> commandQueue ) ; 271if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_CREATE_COMMAND_QUEUE ; 272free ( cmdqueueGroupProperties ) ; 273i = numDevices ; 274j = numDrivers ; 275} 276else { 277k ++ ; 278} 279} 280 281free ( deviceList ) ; 282} 283free ( drivers ) ; 284#elif ( VKFFT_BACKEND == 5 ) 285NS :: Array * devices = MTL :: CopyAllDevices () ; 286MTL :: Device * device = ( MTL :: Device * ) devices -> object ( vkGPU -> device_id ) ; 287vkGPU -> device = device ; 288MTL :: CommandQueue * queue = device -> newCommandQueue () ; 289vkGPU -> queue = queue ; 290#endif 291 292uint64_t isCompilerInitialized = 1 ; 293 294switch ( sample_id ) { 295case 0 : 296{ 297resFFT = sample_0_benchmark_VkFFT_single ( vkGPU , file_output , output , isCompilerInitialized ) ; 298break ; 299} 300case 1 : 301{ 302resFFT = sample_1_benchmark_VkFFT_double ( vkGPU , file_output , output , isCompilerInitialized ) ; 303break ; 304} 305case 2 : 306{ 307resFFT = sample_2_benchmark_VkFFT_half ( vkGPU , file_output , output , isCompilerInitialized ) ; 308break ; 309} 310case 3 : 311{ 312resFFT = sample_3_benchmark_VkFFT_single_3d ( vkGPU , file_output , output , isCompilerInitialized ) ; 313break ; 314} 315case 4 : 316{ 317resFFT = sample_4_benchmark_VkFFT_single_3d_zeropadding ( vkGPU , file_output , output , isCompilerInitialized ) ; 318break ; 319} 320case 5 : 321{ 322resFFT = sample_5_benchmark_VkFFT_single_disableReorderFourStep ( vkGPU , file_output , output , isCompilerInitialized ) ; 323break ; 324} 325case 6 : 326{ 327resFFT = sample_6_benchmark_VkFFT_single_r2c ( vkGPU , file_output , output , isCompilerInitialized ) ; 328break ; 329} 330case 7 : 331{ 332resFFT = sample_7_benchmark_VkFFT_single_Bluestein ( vkGPU , file_output , output , isCompilerInitialized ) ; 333break ; 334} 335case 8 : 336{ 337resFFT = sample_8_benchmark_VkFFT_double_Bluestein ( vkGPU , file_output , output , isCompilerInitialized ) ; 338break ; 339} 340#if ( VKFFT_BACKEND == 0 ) 341case 10 : 342{ 343resFFT = sample_10_benchmark_VkFFT_single_multipleBuffers ( vkGPU , file_output , output , isCompilerInitialized ) ; 344break ; 345} 346#endif 347#ifdef USE_FFTW 348case 11 : 349{ 350resFFT = sample_11_precision_VkFFT_single ( vkGPU , file_output , output , isCompilerInitialized ) ; 351break ; 352} 353case 12 : 354{ 355resFFT = sample_12_precision_VkFFT_double ( vkGPU , file_output , output , isCompilerInitialized ) ; 356break ; 357} 358case 13 : 359{ 360resFFT = sample_13_precision_VkFFT_half ( vkGPU , file_output , output , isCompilerInitialized ) ; 361break ; 362} 363case 14 : 364{ 365resFFT = sample_14_precision_VkFFT_single_nonPow2 ( vkGPU , file_output , output , isCompilerInitialized ) ; 366break ; 367} 368case 15 : 369{ 370resFFT = sample_15_precision_VkFFT_single_r2c ( vkGPU , file_output , output , isCompilerInitialized ) ; 371break ; 372} 373case 16 : 374{ 375resFFT = sample_16_precision_VkFFT_single_dct ( vkGPU , file_output , output , isCompilerInitialized ) ; 376break ; 377} 378case 17 : 379{ 380resFFT = sample_17_precision_VkFFT_double_dct ( vkGPU , file_output , output , isCompilerInitialized ) ; 381break ; 382} 383case 18 : 384{ 385resFFT = sample_18_precision_VkFFT_double_nonPow2 ( vkGPU , file_output , output , isCompilerInitialized ) ; 386break ; 387} 388#endif 389case 50 : 390{ 391resFFT = sample_50_convolution_VkFFT_single_1d_matrix ( vkGPU , file_output , output , isCompilerInitialized ) ; 392break ; 393} 394case 51 : 395{ 396resFFT = sample_51_convolution_VkFFT_single_3d_matrix_zeropadding_r2c ( vkGPU , file_output , output , isCompilerInitialized ) ; 397break ; 398} 399case 52 : 400{ 401resFFT = sample_52_convolution_VkFFT_single_2d_batched_r2c ( vkGPU , file_output , output , isCompilerInitialized ) ; 402break ; 403} 404case 110 : 405{ 406resFFT = sample_100_benchmark_VkFFT_single_nd_dct ( vkGPU , file_output , output , isCompilerInitialized , 1 ) ; 407break ; 408} 409case 120 : 410{ 411resFFT = sample_100_benchmark_VkFFT_single_nd_dct ( vkGPU , file_output , output , isCompilerInitialized , 2 ) ; 412break ; 413} 414case 130 : 415{ 416resFFT = sample_100_benchmark_VkFFT_single_nd_dct ( vkGPU , file_output , output , isCompilerInitialized , 3 ) ; 417break ; 418} 419case 140 : 420{ 421resFFT = sample_100_benchmark_VkFFT_single_nd_dct ( vkGPU , file_output , output , isCompilerInitialized , 4 ) ; 422break ; 423} 424case 111 : 425{ 426resFFT = sample_101_benchmark_VkFFT_double_nd_dct ( vkGPU , file_output , output , isCompilerInitialized , 1 ) ; 427break ; 428} 429case 121 : 430{ 431resFFT = sample_101_benchmark_VkFFT_double_nd_dct ( vkGPU , file_output , output , isCompilerInitialized , 2 ) ; 432break ; 433} 434case 131 : 435{ 436resFFT = sample_101_benchmark_VkFFT_double_nd_dct ( vkGPU , file_output , output , isCompilerInitialized , 3 ) ; 437break ; 438} 439case 141 : 440{ 441resFFT = sample_101_benchmark_VkFFT_double_nd_dct ( vkGPU , file_output , output , isCompilerInitialized , 4 ) ; 442break ; 443} 444case 200 : case 201 : 445{ 446resFFT = user_benchmark_VkFFT ( vkGPU , file_output , output , isCompilerInitialized , userParams ) ; 447break ; 448} 449case 202 : 450{ 451resFFT = user_benchmark_VkFFT ( vkGPU , file_output , output , isCompilerInitialized , userParams ) ; 452break ; 453} 454case 1000 : 455{ 456resFFT = sample_1000_VkFFT_single_2_4096 ( vkGPU , file_output , output , isCompilerInitialized ) ; 457break ; 458} 459case 1001 : 460{ 461resFFT = sample_1001_benchmark_VkFFT_double_2_4096 ( vkGPU , file_output , output , isCompilerInitialized ) ; 462break ; 463} 464case 1003 : 465{ 466resFFT = sample_1003_benchmark_VkFFT_single_3d_2_512 ( vkGPU , file_output , output , isCompilerInitialized ) ; 467break ; 468} 469} 470#if ( VKFFT_BACKEND == 0 ) 471vkDestroyFence ( vkGPU -> device , vkGPU -> fence , NULL ) ; 472vkDestroyCommandPool ( vkGPU -> device , vkGPU -> commandPool , NULL ) ; 473vkDestroyDevice ( vkGPU -> device , NULL ) ; 474DestroyDebugUtilsMessengerEXT ( vkGPU , NULL ) ; 475vkDestroyInstance ( vkGPU -> instance , NULL ) ; 476glslang_finalize_process () ; //destroy compiler after use 477#elif ( VKFFT_BACKEND == 1 ) 478res = cuCtxDestroy ( vkGPU -> context ) ; 479#elif ( VKFFT_BACKEND == 2 ) 480res = hipCtxDestroy ( vkGPU -> context ) ; 481#elif ( VKFFT_BACKEND == 3 ) 482res = clReleaseCommandQueue ( vkGPU -> commandQueue ) ; 483if ( res != CL_SUCCESS ) return VKFFT_ERROR_FAILED_TO_RELEASE_COMMAND_QUEUE ; 484clReleaseContext ( vkGPU -> context ) ; 485#elif ( VKFFT_BACKEND == 4 ) 486res = zeCommandQueueDestroy ( vkGPU -> commandQueue ) ; 487if ( res != ZE_RESULT_SUCCESS ) return VKFFT_ERROR_FAILED_TO_RELEASE_COMMAND_QUEUE ; 488res = zeContextDestroy ( vkGPU -> context ) ; 489#elif ( VKFFT_BACKEND == 5 ) 490vkGPU -> queue -> release () ; 491vkGPU -> device -> release () ; 492devices -> release () ; 493#endif 494 495return resFFT ; 496} 497 498bool findFlag ( char ** start , char ** end , const std :: string & flag ) { 499return ( std :: find ( start , end , flag ) != end ) ; 500} 501char * getFlagValue ( char ** start , char ** end , const std :: string & flag ) 502{ 503char ** value = std :: find ( start , end , flag ) ; 504value ++ ; 505if ( value != end ) 506{ 507return * value ; 508} 509return 0 ; 510} 511int main ( int argc , char * argv []) 512{ 513VkGPU vkGPU = {} ; 514#if ( VKFFT_BACKEND == 0 ) 515vkGPU . enableValidationLayers = 0 ; 516#endif 517bool file_output = false ; 518FILE * output = NULL ; 519int sscanf_res = 0 ; 520if ( findFlag ( argv , argv + argc , "-h" )) 521{ 522//print help 523int version = VkFFTGetVersion () ; 524int version_decomposed [ 3 ] ; 525version_decomposed [ 0 ] = version / 10000 ; 526version_decomposed [ 1 ] = ( version - version_decomposed [ 0 ] * 10000 ) / 100 ; 527version_decomposed [ 2 ] = ( version - version_decomposed [ 0 ] * 10000 - version_decomposed [ 1 ] * 100 ) ; 528printf ( "VkFFT v%d.%d.%d (01-08-2023). Author: Tolmachev Dmitrii \n " , version_decomposed [ 0 ] , version_decomposed [ 1 ] , version_decomposed [ 2 ]) ; 529#if ( VKFFT_BACKEND == 0 ) 530printf ( "Vulkan backend \n " ) ; 531#elif ( VKFFT_BACKEND == 1 ) 532printf ( "CUDA backend \n " ) ; 533#elif ( VKFFT_BACKEND == 2 ) 534printf ( "HIP backend \n " ) ; 535#elif ( VKFFT_BACKEND == 3 ) 536printf ( "OpenCL backend \n " ) ; 537#elif ( VKFFT_BACKEND == 4 ) 538printf ( "Level Zero backend \n " ) ; 539#elif ( VKFFT_BACKEND == 5 ) 540printf ( "Metal backend \n " ) ; 541#endif 542printf ( " -h: print help \n " ) ; 543printf ( " -devices: print the list of available device ids, used as -d argument \n " ) ; 544printf ( " -d X: select device (default 0) \n " ) ; 545printf ( " -o NAME: specify output file path \n " ) ; 546printf ( " -vkfft X: launch VkFFT sample X: \n " ) ; 547printf ( " 0 - FFT + iFFT C2C benchmark 1D batched in single precision \n " ) ; 548printf ( " 1 - FFT + iFFT C2C benchmark 1D batched in double precision LUT \n " ) ; 549printf ( " 2 - FFT + iFFT C2C benchmark 1D batched in half precision \n " ) ; 550printf ( " 3 - FFT + iFFT C2C multidimensional benchmark in single precision \n " ) ; 551printf ( " 4 - FFT + iFFT C2C multidimensional benchmark in single precision, native zeropadding \n " ) ; 552printf ( " 5 - FFT + iFFT C2C benchmark 1D batched in single precision, no reshuffling \n " ) ; 553printf ( " 6 - FFT + iFFT R2C / C2R benchmark \n " ) ; 554printf ( " 7 - FFT + iFFT C2C Bluestein benchmark in single precision \n " ) ; 555printf ( " 8 - FFT + iFFT C2C Bluestein benchmark in double precision \n " ) ; 556#if ( VKFFT_BACKEND == 0 ) 557printf ( " 10 - multiple buffer(4 by default) split version of benchmark 0 \n " ) ; 558#endif 559#ifdef USE_FFTW 560#ifdef USE_cuFFT 561printf ( " 11 - VkFFT / cuFFT / FFTW C2C precision test in single precision \n " ) ; 562printf ( " 12 - VkFFT / cuFFT / FFTW C2C precision test in double precision \n " ) ; 563printf ( " 13 - VkFFT / cuFFT / FFTW C2C precision test in half precision \n " ) ; 564printf ( " 14 - VkFFT / FFTW C2C radix 3 / 5 / 7 / 11 / 13 / Bluestein precision test in single precision \n " ) ; 565printf ( " 15 - VkFFT / cuFFT / FFTW R2C+C2R precision test in single precision \n " ) ; 566printf ( " 16 - VkFFT / FFTW R2R DCT-I, II, III and IV precision test in single precision \n " ) ; 567printf ( " 17 - VkFFT / FFTW R2R DCT-I, II, III and IV precision test in double precision \n " ) ; 568printf ( " 18 - VkFFT / FFTW C2C radix 3 / 5 / 7 / 11 / 13 / Bluestein precision test in double precision \n " ) ; 569#elif USE_rocFFT 570printf ( " 11 - VkFFT / rocFFT / FFTW C2C precision test in single precision \n " ) ; 571printf ( " 12 - VkFFT / rocFFT / FFTW C2C precision test in double precision \n " ) ; 572printf ( " 13 - VkFFT / FFTW C2C precision test in half precision \n " ) ; 573printf ( " 14 - VkFFT / FFTW C2C radix 3 / 5 / 7 / 11 / 13 / Bluestein precision test in single precision \n " ) ; 574printf ( " 15 - VkFFT / rocFFT / FFTW R2C+C2R precision test in single precision \n " ) ; 575printf ( " 16 - VkFFT / FFTW R2R DCT-I, II, III and IV precision test in single precision \n " ) ; 576printf ( " 17 - VkFFT / FFTW R2R DCT-I, II, III and IV precision test in double precision \n " ) ; 577printf ( " 18 - VkFFT / FFTW C2C radix 3 / 5 / 7 / 11 / 13 / Bluestein precision test in double precision \n " ) ; 578#else 579printf ( " 11 - VkFFT / FFTW C2C precision test in single precision \n " ) ; 580printf ( " 12 - VkFFT / FFTW C2C precision test in double precision \n " ) ; 581printf ( " 13 - VkFFT / FFTW C2C precision test in half precision \n " ) ; 582printf ( " 14 - VkFFT / FFTW C2C radix 3 / 5 / 7 / 11 / 13 / Bluestein precision test in single precision \n " ) ; 583printf ( " 15 - VkFFT / FFTW R2C+C2R precision test in single precision \n " ) ; 584printf ( " 16 - VkFFT / FFTW R2R DCT-I, II, III and IV precision test in single precision \n " ) ; 585printf ( " 17 - VkFFT / FFTW R2R DCT-I, II, III and IV precision test in double precision \n " ) ; 586printf ( " 18 - VkFFT / FFTW C2C radix 3 / 5 / 7 / 11 / 13 / Bluestein precision test in double precision \n " ) ; 587#endif 588#endif 589printf ( " 50 - convolution example with identity kernel \n " ) ; 590printf ( " 51 - zeropadding convolution example with identity kernel \n " ) ; 591printf ( " 52 - batched convolution example with identity kernel \n " ) ; 592printf ( " 110 - VkFFT FFT + iFFT R2R DCT-1 multidimensional benchmark in single precision \n " ) ; 593printf ( " 111 - VkFFT FFT + iFFT R2R DCT-1 multidimensional benchmark in double precision \n " ) ; 594printf ( " 120 - VkFFT FFT + iFFT R2R DCT-2 multidimensional benchmark in single precision \n " ) ; 595printf ( " 121 - VkFFT FFT + iFFT R2R DCT-2 multidimensional benchmark in double precision \n " ) ; 596printf ( " 130 - VkFFT FFT + iFFT R2R DCT-3 multidimensional benchmark in single precision \n " ) ; 597printf ( " 131 - VkFFT FFT + iFFT R2R DCT-3 multidimensional benchmark in double precision \n " ) ; 598printf ( " 140 - VkFFT FFT + iFFT R2R DCT-4 multidimensional benchmark in single precision \n " ) ; 599printf ( " 141 - VkFFT FFT + iFFT R2R DCT-4 multidimensional benchmark in double precision \n " ) ; 600 601printf ( " 1000 - FFT + iFFT C2C benchmark 1D batched in single precision: all supported systems from 2 to 4096 \n " ) ; 602printf ( " 1001 - FFT + iFFT C2C benchmark 1D batched in double precision: all supported systems from 2 to 4096 \n " ) ; 603printf ( " 1003 - FFT + iFFT C2C multidimensional benchmark in single precision: all supported cubes from 2 to 512 \n " ) ; 604printf ( " -benchmark_vkfft: run VkFFT benchmark on a user-defined system: \n\ 605-X uint, -Y uint, -Z uint - FFT dimensions (default Y and Z are 1) \n " ) ; 606printf ( " \ 607-P uint - precision (0 - single, 1 - double, 2 - half) (default 0) \n " ) ; 608printf ( " \ 609-B uint - number of batched systems (default 1) \n\ 610-N uint - number of consecutive FFT+iFFT iterations (default 1) \n\ 611-R2C uint - use R2C (0 - off, 1 - on) (default 0) \n\ 612-DCT uint - perform DCT (0 - off, else type: 1, 2, 3 or 4) (default 0) \n\ 613-save - save generated binaries \n\ 614-load - load previously generated binaries \n " ) ; 615#ifdef USE_cuFFT 616printf ( " -cufft X: launch cuFFT sample X: \n " ) ; 617printf ( " 0 - FFT + iFFT C2C benchmark 1D batched in single precision \n " ) ; 618printf ( " 1 - FFT + iFFT C2C benchmark 1D batched in double precision LUT \n " ) ; 619printf ( " 2 - FFT + iFFT C2C benchmark 1D batched in half precision \n " ) ; 620printf ( " 3 - FFT + iFFT C2C multidimensional benchmark in single precision \n " ) ; 621printf ( " 6 - FFT + iFFT R2C / C2R benchmark \n " ) ; 622printf ( " 7 - FFT + iFFT C2C big prime benchmark in single precision (similar to VkFFT Bluestein) \n " ) ; 623printf ( " 8 - FFT + iFFT C2C big prime benchmark in double precision (similar to VkFFT Bluestein) \n " ) ; 624printf ( " 1000 - FFT + iFFT C2C benchmark 1D batched in single precision: all supported systems from 2 to 4096 \n " ) ; 625printf ( " 1001 - FFT + iFFT C2C benchmark 1D batched in double precision: all supported systems from 2 to 4096 \n " ) ; 626printf ( " 1003 - FFT + iFFT C2C multidimensional benchmark in single precision: all supported cubes from 2 to 512 \n " ) ; 627printf ( " -test: (or no -vkfft and -cufft keys) run vkfft benchmarks 0-6 and cufft benchmarks 0-6 \n " ) ; 628printf ( " -benchmark_cufft: run cuFFT benchmark on a user-defined system: \n\ 629-X uint, -Y uint, -Z uint - FFT dimensions (default Y and Z are 1) \n\ 630-P uint - precision (0 - single, 1 - double) (default 0) \n\ 631-B uint - number of batched systems (default 1) \n\ 632-N uint - number of consecutive FFT+iFFT iterations (default 1) \n\ 633-R2C uint - use R2C (0 - off, 1 - on) (default 0) \n " ) ; 634#elif USE_rocFFT 635printf ( " -rocfft X: launch rocFFT sample X: \n " ) ; 636printf ( " 0 - FFT + iFFT C2C benchmark 1D batched in single precision \n " ) ; 637printf ( " 1 - FFT + iFFT C2C benchmark 1D batched in double precision LUT \n " ) ; 638printf ( " 3 - FFT + iFFT C2C multidimensional benchmark in single precision \n " ) ; 639printf ( " 6 - FFT + iFFT R2C / C2R benchmark \n " ) ; 640printf ( " 7 - FFT + iFFT C2C big prime benchmark in single precision (similar to VkFFT Bluestein) \n " ) ; 641printf ( " 8 - FFT + iFFT C2C big prime benchmark in double precision (similar to VkFFT Bluestein) \n " ) ; 642printf ( " 1000 - FFT + iFFT C2C benchmark 1D batched in single precision: all supported systems from 2 to 4096 \n " ) ; 643printf ( " 1001 - FFT + iFFT C2C benchmark 1D batched in double precision: all supported systems from 2 to 4096 \n " ) ; 644printf ( " 1003 - FFT + iFFT C2C multidimensional benchmark in single precision: all supported cubes from 2 to 512 \n " ) ; 645printf ( " -test: (or no -vkfft and -rocfft keys) run vkfft benchmarks 0-6 and rocfft benchmarks 0-6 \n " ) ; 646printf ( " -benchmark_rocfft: run rocFFT benchmark on a user-defined system: \n\ 647-X uint, -Y uint, -Z uint - FFT dimensions (default Y and Z are 1) \n\ 648-P uint - precision (0 - single, 1 - double) (default 0) \n\ 649-B uint - number of batched systems (default 1) \n\ 650-N uint - number of consecutive FFT+iFFT iterations (default 1) \n\ 651-R2C uint - use R2C (0 - off, 1 - on) (default 0) \n " ) ; 652#else 653printf ( " -test: run vkfft benchmarks 0-6 \n " ) ; 654printf ( " -cufft command is disabled \n " ) ; 655printf ( " -rocfft command is disabled \n " ) ; 656#endif 657return 0 ; 658} 659if ( findFlag ( argv , argv + argc , "-devices" )) 660{ 661//print device list 662VkFFTResult resFFT = devices_list () ; 663return resFFT ; 664} 665if ( findFlag ( argv , argv + argc , "-d" )) 666{ 667//select device_id 668char * value = getFlagValue ( argv , argv + argc , "-d" ) ; 669if ( value != 0 ) { 670sscanf_res = sscanf ( value , "%" PRIu64 "" , & vkGPU . device_id ) ; 671if ( sscanf_res <= 0 ) { 672printf ( "sscanf failed \n " ) ; 673return 1 ; 674} 675} 676else { 677printf ( "No device is selected with -d flag \n " ) ; 678return 1 ; 679} 680} 681if ( findFlag ( argv , argv + argc , "-o" )) 682{ 683//specify output file 684char * value = getFlagValue ( argv , argv + argc , "-o" ) ; 685if ( value != 0 ) { 686file_output = true ; 687output = fopen ( value , "a" ) ; 688} 689else { 690printf ( "No output file is selected with -o flag \n " ) ; 691return 1 ; 692} 693} 694if ( findFlag ( argv , argv + argc , "-benchmark_vkfft" ) || findFlag ( argv , argv + argc , "-benchmark_cufft" ) || findFlag ( argv , argv + argc , "-benchmark_rocfft" )) 695{ 696//select sample_id 697VkFFTUserSystemParameters userParams = {} ; 698userParams . X = 1 ; 699userParams . Y = 1 ; 700userParams . Z = 1 ; 701userParams . P = 0 ; 702userParams . B = 1 ; 703userParams . N = 1 ; 704userParams . R2C = 0 ; 705userParams . DCT = 0 ; 706if ( findFlag ( argv , argv + argc , "-X" )) 707{ 708char * value = getFlagValue ( argv , argv + argc , "-X" ) ; 709if ( value != 0 ) { 710sscanf_res = sscanf ( value , "%" PRIu64 "" , & userParams . X ) ; 711if ( sscanf_res <= 0 ) { 712printf ( "sscanf failed \n " ) ; 713return 1 ; 714} 715} 716else { 717printf ( "No dimension is selected with -X flag \n " ) ; 718return 1 ; 719} 720} 721else { 722printf ( "No -X flag is selected \n " ) ; 723return 1 ; 724} 725if ( findFlag ( argv , argv + argc , "-Y" )) 726{ 727char * value = getFlagValue ( argv , argv + argc , "-Y" ) ; 728if ( value != 0 ) { 729sscanf_res = sscanf ( value , "%" PRIu64 "" , & userParams . Y ) ; 730if ( sscanf_res <= 0 ) { 731printf ( "sscanf failed \n " ) ; 732return 1 ; 733} 734} 735else { 736printf ( "No dimension is selected with -Y flag \n " ) ; 737return 1 ; 738} 739} 740if ( findFlag ( argv , argv + argc , "-Z" )) 741{ 742char * value = getFlagValue ( argv , argv + argc , "-Z" ) ; 743if ( value != 0 ) { 744sscanf_res = sscanf ( value , "%" PRIu64 "" , & userParams . Z ) ; 745if ( sscanf_res <= 0 ) { 746printf ( "sscanf failed \n " ) ; 747return 1 ; 748} 749} 750else { 751printf ( "No dimension is selected with -Z flag \n " ) ; 752return 1 ; 753} 754} 755if ( findFlag ( argv , argv + argc , "-P" )) 756{ 757char * value = getFlagValue ( argv , argv + argc , "-P" ) ; 758if ( value != 0 ) { 759sscanf_res = sscanf ( value , "%" PRIu64 "" , & userParams . P ) ; 760if ( sscanf_res <= 0 ) { 761printf ( "sscanf failed \n " ) ; 762return 1 ; 763} 764} 765else { 766printf ( "No precision is selected with -P flag \n " ) ; 767return 1 ; 768} 769} 770if ( findFlag ( argv , argv + argc , "-B" )) 771{ 772char * value = getFlagValue ( argv , argv + argc , "-B" ) ; 773if ( value != 0 ) { 774sscanf_res = sscanf ( value , "%" PRIu64 "" , & userParams . B ) ; 775if ( sscanf_res <= 0 ) { 776printf ( "sscanf failed \n " ) ; 777return 1 ; 778} 779} 780else { 781printf ( "No batch is selected with -B flag \n " ) ; 782return 1 ; 783} 784} 785if ( findFlag ( argv , argv + argc , "-N" )) 786{ 787char * value = getFlagValue ( argv , argv + argc , "-N" ) ; 788if ( value != 0 ) { 789sscanf_res = sscanf ( value , "%" PRIu64 "" , & userParams . N ) ; 790if ( sscanf_res <= 0 ) { 791printf ( "sscanf failed \n " ) ; 792return 1 ; 793} 794} 795else { 796printf ( "No number of iterations is selected with -N flag \n " ) ; 797return 1 ; 798} 799} 800if ( findFlag ( argv , argv + argc , "-R2C" )) 801{ 802char * value = getFlagValue ( argv , argv + argc , "-R2C" ) ; 803if ( value != 0 ) { 804sscanf_res = sscanf ( value , "%" PRIu64 "" , & userParams . R2C ) ; 805if ( sscanf_res <= 0 ) { 806printf ( "sscanf failed \n " ) ; 807return 1 ; 808} 809} 810else { 811printf ( "No R2C parameter is selected with -R2C flag \n " ) ; 812return 1 ; 813} 814} 815if ( findFlag ( argv , argv + argc , "-DCT" )) 816{ 817char * value = getFlagValue ( argv , argv + argc , "-DCT" ) ; 818if ( value != 0 ) { 819sscanf_res = sscanf ( value , "%" PRIu64 "" , & userParams . DCT ) ; 820if ( sscanf_res <= 0 ) { 821printf ( "sscanf failed \n " ) ; 822return 1 ; 823} 824} 825else { 826printf ( "No DCT parameter is selected with -DCT flag \n " ) ; 827return 1 ; 828} 829} 830if ( findFlag ( argv , argv + argc , "-save" )) 831{ 832userParams . saveApplicationToString = 1 ; 833} 834if ( findFlag ( argv , argv + argc , "-load" )) 835{ 836userParams . loadApplicationFromString = 1 ; 837} 838if ( findFlag ( argv , argv + argc , "-benchmark_vkfft" )) { 839VkFFTResult resFFT = launchVkFFT ( & vkGPU , 200 + userParams . P , file_output , output , & userParams ) ; 840if ( resFFT != VKFFT_SUCCESS ) return resFFT ; 841} 842else { 843#ifdef USE_cuFFT 844if ( findFlag ( argv , argv + argc , "-benchmark_cufft" )) { 845user_benchmark_cuFFT ( file_output , output , ( cuFFTUserSystemParameters * )( & userParams ) , ( int ) vkGPU . device_id ) ; 846} 847return 0 ; 848#elif USE_rocFFT 849if ( findFlag ( argv , argv + argc , "-benchmark_rocfft" )) { 850user_benchmark_rocFFT ( file_output , output , ( rocFFTUserSystemParameters * )( & userParams ) , ( int ) vkGPU . device_id ) ; 851} 852return 0 ; 853#endif 854return 1 ; 855} 856return 0 ; 857} 858 859if ( findFlag ( argv , argv + argc , "-vkfft" )) 860{ 861//select sample_id 862char * value = getFlagValue ( argv , argv + argc , "-vkfft" ) ; 863if ( value != 0 ) { 864uint64_t sample_id = 0 ; 865sscanf_res = sscanf ( value , "%" PRIu64 "" , & sample_id ) ; 866if ( sscanf_res <= 0 ) { 867printf ( "sscanf failed \n " ) ; 868return 1 ; 869} 870VkFFTResult resFFT = launchVkFFT ( & vkGPU , sample_id , file_output , output , 0 ) ; 871if ( resFFT != VKFFT_SUCCESS ) return resFFT ; 872} 873else { 874printf ( "No sample is selected with -vkfft flag \n " ) ; 875return 1 ; 876} 877} 878#ifdef USE_cuFFT 879if ( findFlag ( argv , argv + argc , "-cufft" )) 880{ 881//select sample_id 882char * value = getFlagValue ( argv , argv + argc , "-cufft" ) ; 883if ( value != 0 ) { 884uint64_t sample_id = 0 ; 885sscanf_res = sscanf ( value , "%" PRIu64 "" , & sample_id ) ; 886if ( sscanf_res <= 0 ) { 887printf ( "sscanf failed \n " ) ; 888return 1 ; 889} 890switch ( sample_id ) { 891case 0 : 892sample_0_benchmark_cuFFT_single ( file_output , output , ( int ) vkGPU . device_id ) ; 893break ; 894case 1 : 895sample_1_benchmark_cuFFT_double ( file_output , output , ( int ) vkGPU . device_id ) ; 896break ; 897case 2 : 898sample_2_benchmark_cuFFT_half ( file_output , output , ( int ) vkGPU . device_id ) ; 899break ; 900case 3 : 901sample_3_benchmark_cuFFT_single_3d ( file_output , output , ( int ) vkGPU . device_id ) ; 902break ; 903case 6 : 904sample_6_benchmark_cuFFT_single_r2c ( file_output , output , ( int ) vkGPU . device_id ) ; 905break ; 906case 7 : 907sample_7_benchmark_cuFFT_single_Bluestein ( file_output , output , ( int ) vkGPU . device_id ) ; 908break ; 909case 8 : 910sample_8_benchmark_cuFFT_double_Bluestein ( file_output , output , ( int ) vkGPU . device_id ) ; 911break ; 912case 1000 : 913sample_1000_benchmark_cuFFT_single_2_4096 ( file_output , output , ( int ) vkGPU . device_id ) ; 914break ; 915case 1001 : 916sample_1001_benchmark_cuFFT_double_2_4096 ( file_output , output , ( int ) vkGPU . device_id ) ; 917break ; 918case 1003 : 919sample_1003_benchmark_cuFFT_single_3d_2_512 ( file_output , output , ( int ) vkGPU . device_id ) ; 920break ; 921} 922} 923else { 924printf ( "No cuFFT script is selected with -cufft flag \n " ) ; 925return 1 ; 926} 927} 928#elif USE_rocFFT 929if ( findFlag ( argv , argv + argc , "-rocfft" )) 930{ 931//select sample_id 932char * value = getFlagValue ( argv , argv + argc , "-rocfft" ) ; 933if ( value != 0 ) { 934uint64_t sample_id = 0 ; 935sscanf_res = sscanf ( value , "%" PRIu64 "" , & sample_id ) ; 936if ( sscanf_res <= 0 ) { 937printf ( "sscanf failed \n " ) ; 938return 1 ; 939} 940switch ( sample_id ) { 941case 0 : 942sample_0_benchmark_rocFFT_single ( file_output , output , ( int ) vkGPU . device_id ) ; 943break ; 944case 1 : 945sample_1_benchmark_rocFFT_double ( file_output , output , ( int ) vkGPU . device_id ) ; 946break ; 947case 3 : 948sample_3_benchmark_rocFFT_single_3d ( file_output , output , ( int ) vkGPU . device_id ) ; 949break ; 950case 6 : 951sample_6_benchmark_rocFFT_single_r2c ( file_output , output , ( int ) vkGPU . device_id ) ; 952break ; 953case 7 : 954sample_7_benchmark_rocFFT_single_Bluestein ( file_output , output , ( int ) vkGPU . device_id ) ; 955break ; 956case 8 : 957sample_8_benchmark_rocFFT_double_Bluestein ( file_output , output , ( int ) vkGPU . device_id ) ; 958break ; 959case 1000 : 960sample_1000_benchmark_rocFFT_single_2_4096 ( file_output , output , ( int ) vkGPU . device_id ) ; 961break ; 962case 1001 : 963sample_1001_benchmark_rocFFT_double_2_4096 ( file_output , output , ( int ) vkGPU . device_id ) ; 964break ; 965case 1003 : 966sample_1003_benchmark_rocFFT_single_3d_2_512 ( file_output , output , ( int ) vkGPU . device_id ) ; 967break ; 968} 969} 970else { 971printf ( "No rocFFT script is selected with -rocfft flag \n " ) ; 972return 1 ; 973} 974} 975#endif 976if (( findFlag ( argv , argv + argc , "-test" )) || (( ! findFlag ( argv , argv + argc , "-cufft" )) && ( ! findFlag ( argv , argv + argc , "-rocfft" )) && ( ! findFlag ( argv , argv + argc , "-vkfft" )))) 977{ 978if ( output == NULL ) { 979file_output = true ; 980output = fopen ( "result.txt" , "a" ) ; 981} 982for ( uint64_t i = 0 ; i < 9 ; i ++ ) { 983#if (( VKFFT_BACKEND > 0 ) || ( VK_API_VERSION == 10 )) 984if ( i == 2 ) i ++ ; 985#endif 986VkFFTResult resFFT = launchVkFFT ( & vkGPU , i , file_output , output , 0 ) ; 987if ( resFFT != VKFFT_SUCCESS ) return resFFT ; 988} 989#ifdef USE_cuFFT 990sample_0_benchmark_cuFFT_single ( file_output , output , ( int ) vkGPU . device_id ) ; 991sample_1_benchmark_cuFFT_double ( file_output , output , ( int ) vkGPU . device_id ) ; 992sample_2_benchmark_cuFFT_half ( file_output , output , ( int ) vkGPU . device_id ) ; 993sample_3_benchmark_cuFFT_single_3d ( file_output , output , ( int ) vkGPU . device_id ) ; 994sample_6_benchmark_cuFFT_single_r2c ( file_output , output , ( int ) vkGPU . device_id ) ; 995sample_7_benchmark_cuFFT_single_Bluestein ( file_output , output , ( int ) vkGPU . device_id ) ; 996sample_8_benchmark_cuFFT_double_Bluestein ( file_output , output , ( int ) vkGPU . device_id ) ; 997#elif USE_rocFFT 998sample_0_benchmark_rocFFT_single ( file_output , output , ( int ) vkGPU . device_id ) ; 999sample_1_benchmark_rocFFT_double ( file_output , output , ( int ) vkGPU . device_id ) ; 1000sample_3_benchmark_rocFFT_single_3d ( file_output , output , ( int ) vkGPU . device_id ) ; 1001sample_6_benchmark_rocFFT_single_r2c ( file_output , output , ( int ) vkGPU . device_id ) ; 1002sample_7_benchmark_rocFFT_single_Bluestein ( file_output , output , ( int ) vkGPU . device_id ) ; 1003sample_8_benchmark_rocFFT_double_Bluestein ( file_output , output , ( int ) vkGPU . device_id ) ; 1004#endif 1005} 1006return 0 ; 1007}