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