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