From 0de22c25a52e2ebc3745268abfa1e1dbe9642876 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Sat, 16 Jun 2018 16:52:03 +1000 Subject: [PATCH 01/14] Disable clfftTeardown() warning --- src/library/repo.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/library/repo.h b/src/library/repo.h index 6b5acda7..dfe1e98a 100644 --- a/src/library/repo.h +++ b/src/library/repo.h @@ -170,6 +170,7 @@ class FFTRepo // violation could occur. //releaseResources( ); +#ifdef _DEBUG // We should at least print out a warning message to the user if we are in our destructor and we still have resources // bound. This should give the user a clue to remember to call clfftTeardown( ) if( (!mapKernels.empty( )) || (!mapFFTs.empty( )) ) @@ -177,6 +178,7 @@ class FFTRepo terr << _T( "Warning: Program terminating, but clFFT resources not freed." ) << std::endl; terr << _T( "Please consider explicitly calling clfftTeardown( )." ) << std::endl; } +#endif }; public: From 87a5bccc2f4c9f19b3164dde91e9250fcad74bf1 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Sat, 16 Jun 2018 17:21:53 +1000 Subject: [PATCH 02/14] Disable clBuildProgram() warnings --- src/callback-client/callback-client.cpp | 2 +- src/library/enqueue.cpp | 2 +- src/library/fft_binary_lookup.cpp | 6 ++++-- src/library/private.h | 6 ++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/callback-client/callback-client.cpp b/src/callback-client/callback-client.cpp index e569b657..b31a0981 100644 --- a/src/callback-client/callback-client.cpp +++ b/src/callback-client/callback-client.cpp @@ -330,7 +330,7 @@ void runR2C_FFT_PreAndPostprocessKernel(std::auto_ptr< clfftSetupData > setupDat cl_program program = clCreateProgramWithSource( context, 1, &source, NULL, &status ); OPENCL_V_THROW( status, "clCreateProgramWithSource failed." ); - status = clBuildProgram( program, 1, &device_id, "", NULL, NULL); + status = clBuildProgram( program, 1, &device_id, CL_OPTIONS, NULL, NULL); OPENCL_V_THROW( status, "clBuildProgram failed" ); #if defined( _DEBUG ) diff --git a/src/library/enqueue.cpp b/src/library/enqueue.cpp index f5ee01b3..1f89ef00 100644 --- a/src/library/enqueue.cpp +++ b/src/library/enqueue.cpp @@ -755,7 +755,7 @@ clfftStatus FFTAction::compileKernels( const cl_command_queue commQueueFFT, cons __debugbreak(); #endif #else - status = clBuildProgram( program, 1, &q_device, "", NULL, NULL); + status = clBuildProgram( program, 1, &q_device, CL_OPTIONS, NULL, NULL); #endif if( status != CL_SUCCESS ) { diff --git a/src/library/fft_binary_lookup.cpp b/src/library/fft_binary_lookup.cpp index ff386e28..f5c8b6e2 100644 --- a/src/library/fft_binary_lookup.cpp +++ b/src/library/fft_binary_lookup.cpp @@ -560,7 +560,8 @@ cl_int FFTBinaryLookup::buildFromSource(const char * source) this->m_program = FFTBinaryLookup::buildProgramFromSource(source, this->m_context, this->m_device, - err); + err, + CL_OPTIONS); if (err != CL_SUCCESS) { @@ -581,7 +582,8 @@ cl_int FFTBinaryLookup::buildFromLoadedBinary(const void * data, len, this->m_context, this->m_device, - err); + err, + CL_OPTIONS); return err; } diff --git a/src/library/private.h b/src/library/private.h index 48f2fa5e..6824ec98 100644 --- a/src/library/private.h +++ b/src/library/private.h @@ -29,6 +29,12 @@ #include "../include/clFFT.h" #include "../include/unicode.compatibility.h" +#ifdef _DEBUG + #define CL_OPTIONS "" +#else + #define CL_OPTIONS "-w" +#endif + #if defined(_MSC_VER) // Microsoft Visual C++ compiler // From 9ca3d749a81965bdd05359b7c16041275c77d438 Mon Sep 17 00:00:00 2001 From: bragadeesh Date: Fri, 30 Jun 2017 13:51:56 -0700 Subject: [PATCH 03/14] adding explicit cast for float4 pointer assignments --- src/library/generator.stockham.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/generator.stockham.cpp b/src/library/generator.stockham.cpp index f100c112..bc57d965 100644 --- a/src/library/generator.stockham.cpp +++ b/src/library/generator.stockham.cpp @@ -820,7 +820,8 @@ namespace StockhamGenerator passStr += "\n\t"; passStr += "__global "; passStr += RegBaseType(4); - passStr += " *buff4g = "; passStr += bufferRe; passStr += ";\n\t"; // Assuming 'outOffset' is 0, so not adding it here + passStr += " *buff4g = (__global "; passStr += RegBaseType(4); passStr += " *)"; + passStr += bufferRe; passStr += ";\n\t"; // Assuming 'outOffset' is 0, so not adding it here for(size_t r=0; r Date: Mon, 27 Nov 2017 12:26:23 -0800 Subject: [PATCH 04/14] remove cb constant attribute --- src/library/generator.stockham.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/library/generator.stockham.cpp b/src/library/generator.stockham.cpp index bc57d965..c2f6fa78 100644 --- a/src/library/generator.stockham.cpp +++ b/src/library/generator.stockham.cpp @@ -3469,19 +3469,7 @@ namespace StockhamGenerator else str += "fft_back"; str += "("; - // TODO : address this kludge - size_t SizeParam_ret = 0; - clGetDeviceInfo(Dev_ID, CL_DEVICE_VENDOR, 0, NULL, &SizeParam_ret); - char* nameVendor = new char[SizeParam_ret]; - clGetDeviceInfo(Dev_ID, CL_DEVICE_VENDOR, SizeParam_ret, nameVendor, NULL); - - //nv compiler doesn't support __constant kernel argument - if (strncmp(nameVendor, "NVIDIA",6)!=0) - str += "__constant cb_t *cb __attribute__((max_constant_size(32))), "; - else - str += "__global cb_t *cb, "; - - delete [] nameVendor; + str += "__global cb_t *cb, "; //If plan has pre/post callback callbackstr.clear(); From 14d58888a7ca493bfcecde376bf5a58ba1b32d5a Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Sat, 16 Jun 2018 22:11:06 +1000 Subject: [PATCH 05/14] Add missing const qualifiers for inputs Avoids warnings when using Intel and pocl runtime, e.g.: warning: assigning to '__global double2 *' from 'const __global double2 *' discards qualifiers --- src/library/generator.copy.cpp | 6 ++-- src/library/generator.stockham.cpp | 54 +++++++++++++++--------------- src/tests/test_constants.h | 16 ++++----- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/library/generator.copy.cpp b/src/library/generator.copy.cpp index b55f5992..a80bc775 100644 --- a/src/library/generator.copy.cpp +++ b/src/library/generator.copy.cpp @@ -258,12 +258,12 @@ namespace CopyGenerator // input if(inIlvd) { - str += "__global "; str += r2Type; str += " *lwbIn;\n\t"; + str += "__global const "; str += r2Type; str += " *lwbIn;\n\t"; } else { - str += "__global "; str += rType; str += " *lwbInRe;\n\t"; - str += "__global "; str += rType; str += " *lwbInIm;\n\t"; + str += "__global const "; str += rType; str += " *lwbInRe;\n\t"; + str += "__global const "; str += rType; str += " *lwbInIm;\n\t"; } } diff --git a/src/library/generator.stockham.cpp b/src/library/generator.stockham.cpp index c2f6fa78..57720ce3 100644 --- a/src/library/generator.stockham.cpp +++ b/src/library/generator.stockham.cpp @@ -2098,20 +2098,20 @@ namespace StockhamGenerator { if(inInterleaved) { - passStr += "__global "; passStr += regB2Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; - if(!rcSimple) { passStr += "__global "; passStr += regB2Type; passStr += " *"; passStr += bufferInRe2; passStr += ", "; } + passStr += "__global const "; passStr += regB2Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; + if(!rcSimple) { passStr += "__global const "; passStr += regB2Type; passStr += " *"; passStr += bufferInRe2; passStr += ", "; } } else if(inReal) { - passStr += "__global "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; - if(!rcSimple) { passStr += "__global "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe2; passStr += ", "; } + passStr += "__global const "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; + if(!rcSimple) { passStr += "__global const "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe2; passStr += ", "; } } else { - passStr += "__global "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; - if(!rcSimple) { passStr += "__global "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe2; passStr += ", "; } - passStr += "__global "; passStr += regB1Type; passStr += " *"; passStr += bufferInIm; passStr += ", "; - if(!rcSimple) { passStr += "__global "; passStr += regB1Type; passStr += " *"; passStr += bufferInIm2; passStr += ", "; } + passStr += "__global const "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; + if(!rcSimple) { passStr += "__global const "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe2; passStr += ", "; } + passStr += "__global const "; passStr += regB1Type; passStr += " *"; passStr += bufferInIm; passStr += ", "; + if(!rcSimple) { passStr += "__global const "; passStr += regB1Type; passStr += " *"; passStr += bufferInIm2; passStr += ", "; } } } else @@ -2152,24 +2152,24 @@ namespace StockhamGenerator { if(inInterleaved) { - passStr += "__global "; passStr += regB2Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; + passStr += "__global const "; passStr += regB2Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; } else { - passStr += "__global "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; - passStr += "__global "; passStr += regB1Type; passStr += " *"; passStr += bufferInIm; passStr += ", "; + passStr += "__global const "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; + passStr += "__global const "; passStr += regB1Type; passStr += " *"; passStr += bufferInIm; passStr += ", "; } } else { if(inInterleaved) { - passStr += "__local "; passStr += regB2Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; + passStr += "__local const "; passStr += regB2Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; } else { - passStr += "__local "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; - passStr += "__local "; passStr += regB1Type; passStr += " *"; passStr += bufferInIm; passStr += ", "; + passStr += "__local const "; passStr += regB1Type; passStr += " *"; passStr += bufferInRe; passStr += ", "; + passStr += "__local const "; passStr += regB1Type; passStr += " *"; passStr += bufferInIm; passStr += ", "; } } @@ -3553,11 +3553,11 @@ namespace StockhamGenerator { if(inInterleaved) { - str += "__global "; str += r2Type; str += " * restrict gbIn, "; + str += "__global const "; str += r2Type; str += " * restrict gbIn, "; } else if(inReal) { - str += "__global "; str += rType; str += " * restrict gbIn, "; + str += "__global const "; str += rType; str += " * restrict gbIn, "; } else { @@ -3664,22 +3664,22 @@ namespace StockhamGenerator { if(inInterleaved) { - if(!rcSimple) { str += "__global "; str += r2Type; str += " *lwbIn2;\n\t"; } - str += "__global "; str += r2Type; str += " *lwbIn;\n\t"; + if(!rcSimple) { str += "__global const "; str += r2Type; str += " *lwbIn2;\n\t"; } + str += "__global const "; str += r2Type; str += " *lwbIn;\n\t"; } else if(inReal) { - if(!rcSimple) { str += "__global "; str += rType; str += " *lwbIn2;\n\t"; } - str += "__global "; str += rType; str += " *lwbIn;\n\t"; + if(!rcSimple) { str += "__global const "; str += rType; str += " *lwbIn2;\n\t"; } + str += "__global const "; str += rType; str += " *lwbIn;\n\t"; } else { - if(!rcSimple) { str += "__global "; str += rType; str += " *lwbInRe2;\n\t"; } - if(!rcSimple) { str += "__global "; str += rType; str += " *lwbInIm2;\n\t"; } + if(!rcSimple) { str += "__global const "; str += rType; str += " *lwbInRe2;\n\t"; } + if(!rcSimple) { str += "__global const "; str += rType; str += " *lwbInIm2;\n\t"; } - str += "__global "; str += rType; str += " *lwbInRe;\n\t"; - str += "__global "; str += rType; str += " *lwbInIm;\n\t"; + str += "__global const "; str += rType; str += " *lwbInRe;\n\t"; + str += "__global const "; str += rType; str += " *lwbInIm;\n\t"; } } @@ -3743,12 +3743,12 @@ namespace StockhamGenerator { if(inInterleaved) { - str += "__global "; str += r2Type; str += " *lwbIn;\n\t"; + str += "__global const "; str += r2Type; str += " *lwbIn;\n\t"; } else { - str += "__global "; str += rType; str += " *lwbInRe;\n\t"; - str += "__global "; str += rType; str += " *lwbInIm;\n\t"; + str += "__global const "; str += rType; str += " *lwbInRe;\n\t"; + str += "__global const "; str += rType; str += " *lwbInIm;\n\t"; } } diff --git a/src/tests/test_constants.h b/src/tests/test_constants.h index b882ead4..3d689162 100644 --- a/src/tests/test_constants.h +++ b/src/tests/test_constants.h @@ -24,7 +24,7 @@ #include //Pre-callback function strings -#define PRE_MULVAL float2 mulval_pre(__global void* in, uint offset, __global void* userdata)\n \ +#define PRE_MULVAL float2 mulval_pre(__global const void* in, uint offset, __global void* userdata)\n \ { \n \ float scalar = *((__global float*)userdata + offset); \n \ float2 ret = *((__global float2*)in + offset) * scalar; \n \ @@ -36,7 +36,7 @@ float scalar1; \ float scalar2; \ } USER_DATA; \n \ - float2 mulval_pre(__global void* in, uint offset, __global void* userdata)\n \ + float2 mulval_pre(__global const void* in, uint offset, __global void* userdata)\n \ { \n \ __global USER_DATA *data = ((__global USER_DATA *)userdata + offset); \n \ float scalar = data->scalar1 * data->scalar2; \n \ @@ -44,14 +44,14 @@ return ret; \n \ } -#define PRE_MULVAL_DP double2 mulval_pre(__global void* in, uint offset, __global void* userdata)\n \ +#define PRE_MULVAL_DP double2 mulval_pre(__global const void* in, uint offset, __global void* userdata)\n \ { \n \ double scalar = *((__global double*)userdata + offset); \n \ double2 ret = *((__global double2*)in + offset) * scalar; \n \ return ret; \n \ } -#define PRE_MULVAL_PLANAR float2 mulval_pre(__global void* inRe, __global void* inIm, uint offset, __global void* userdata)\n \ +#define PRE_MULVAL_PLANAR float2 mulval_pre(__global const void* inRe, __global const void* inIm, uint offset, __global void* userdata)\n \ { \n \ float scalar = *((__global float*)userdata + offset); \n \ float2 ret; \n \ @@ -60,7 +60,7 @@ return ret; \n \ } -#define PRE_MULVAL_PLANAR_DP double2 mulval_pre(__global void* inRe, __global void* inIm, uint offset, __global void* userdata)\n \ +#define PRE_MULVAL_PLANAR_DP double2 mulval_pre(__global const void* inRe, __global const void* inIm, uint offset, __global void* userdata)\n \ { \n \ double scalar = *((__global double*)userdata + offset); \n \ double2 ret; \n \ @@ -69,14 +69,14 @@ return ret; \n \ } -#define PRE_MULVAL_REAL float mulval_pre(__global void* in, uint offset, __global void* userdata)\n \ +#define PRE_MULVAL_REAL float mulval_pre(__global const void* in, uint offset, __global void* userdata)\n \ { \n \ float scalar = *((__global float*)userdata + offset); \n \ float ret = *((__global float*)in + offset) * scalar; \n \ return ret; \n \ } -#define PRE_MULVAL_REAL_DP double mulval_pre(__global void* in, uint offset, __global void* userdata)\n \ +#define PRE_MULVAL_REAL_DP double mulval_pre(__global const void* in, uint offset, __global void* userdata)\n \ { \n \ double scalar = *((__global double*)userdata + offset); \n \ double ret = *((__global double*)in + offset) * scalar; \n \ @@ -84,7 +84,7 @@ } //Precallback test for LDS - works when 1 WI works on one input element -#define PRE_MULVAL_LDS float2 mulval_pre(__global void* in, uint offset, __global void* userdata, __local void* localmem)\n \ +#define PRE_MULVAL_LDS float2 mulval_pre(__global const void* in, uint offset, __global void* userdata, __local void* localmem)\n \ { \n \ uint lid = get_local_id(0); \n \ __local float* lds = (__local float*)localmem + lid; \n \ From 0c40b932b350e807db8fe1d3979470ce4eb0f2e4 Mon Sep 17 00:00:00 2001 From: pradeep Date: Wed, 4 Nov 2020 13:58:53 +0530 Subject: [PATCH 06/14] Changes to CMakeLists.txt to suite downstream ArrayFire's needs Also renamed cmake options of clFFT project to have CLFFT to avoid name conflicts and confusion when cache variables show up in ArrayFire builds. Add PIC flag for static build --- src/CMakeLists.txt | 125 ++++++++++-------------- src/FindOpenCL.cmake | 6 +- src/callback-client/CMakeLists.txt | 10 +- src/clFFTConfigVersion.cmake.in | 13 +-- src/client/CMakeLists.txt | 10 +- src/examples/CMakeLists.txt | 2 +- src/include/clFFT.version.h.in | 6 +- src/library/CMakeLists.txt | 29 ++++-- src/library/clFFT.pc.in | 6 +- src/scripts/perf/CMakeLists.txt | 2 +- src/statTimer/CMakeLists.txt | 16 +-- src/tests/CMakeLists.txt | 4 +- src/tests/copyTestDependencies.cmake.in | 4 +- 13 files changed, 108 insertions(+), 125 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee2600b9..ffb8fcdf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,45 +14,25 @@ # limitations under the License. # ######################################################################## -if( WIN32 ) - # We require 2.8.3 for windows because of a bug in cmake that prevented vs2010 from generating - # executables properly with multiple periods - cmake_minimum_required( VERSION 2.8.3 ) -else( ) - cmake_minimum_required( VERSION 2.6 ) -endif( ) +cmake_minimum_required(VERSION 3.5) + +cmake_policy(SET CMP0077 NEW) -if( CMAKE_GENERATOR MATCHES "NMake" ) - option( NMAKE_COMPILE_VERBOSE "Print compile and link strings to the console" OFF ) - if( NMAKE_COMPILE_VERBOSE ) +if(CMAKE_GENERATOR MATCHES "NMake") + option(NMAKE_COMPILE_VERBOSE "Print compile and link strings to the console" OFF) + if(NMAKE_COMPILE_VERBOSE) set( CMAKE_START_TEMP_FILE "" ) set( CMAKE_END_TEMP_FILE "" ) set( CMAKE_VERBOSE_MAKEFILE 1 ) - endif( ) -endif( ) - -# This becomes the name of the solution file -project( clFFT ) - -# Define a version for the code -if( NOT DEFINED CLFFT_VERSION_MAJOR ) - set( CLFFT_VERSION_MAJOR 2 ) -endif( ) - -if( NOT DEFINED CLFFT_VERSION_MINOR ) - set( CLFFT_VERSION_MINOR 12 ) -endif( ) - -if( NOT DEFINED CLFFT_VERSION_PATCH ) - set( CLFFT_VERSION_PATCH 2 ) -endif( ) + endif() +endif() -set( CLFFT_VERSION "${CLFFT_VERSION_MAJOR}.${CLFFT_VERSION_MINOR}.${CLFFT_VERSION_PATCH}") +project(clFFT VERSION 2.12.2 LANGUAGES C CXX) -# This is incremented when the ABI to the library changes -set( CLFFT_SOVERSION 2 ) +# save any current module search path for restoration at end of script +set(old_module_path ${CMAKE_MODULE_PATH}) -set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR} ) +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) # On windows, it's convenient to change the default install prefix such that it does NOT point to 'program files' # Need to check out CMAKE_RUNTIME_OUTPUT_DIRECTORY variable, and see if that eliminates the need to modify install path @@ -66,13 +46,13 @@ if( NOT MSVC_IDE AND NOT CMAKE_BUILD_TYPE ) endif() # Options that the user or driver program can set to control various components of the build -option( BUILD_RUNTIME "Build the FFT runtime library" ON ) -option( BUILD_CLIENT "Build a command line clFFT client program with a variety of configurable parameters (dependency on Boost)" OFF ) -option( BUILD_TEST "Build the library testing suite (dependency on google test, Boost, and FFTW)" OFF ) -option( BUILD_LOADLIBRARIES "Build the optional dynamic load libraries that the FFT runtime will search for" ON ) -option( BUILD_SHARED_LIBS "Build shared libraries." ON ) -option( BUILD_EXAMPLES "Build examples." ON ) -option( BUILD_CALLBACK_CLIENT "Build a command line clFFT client program that tests callback functionality (dependency on Boost)" OFF ) +option( CLFFT_BUILD_RUNTIME "Build the FFT runtime library" ON ) +option( CLFFT_BUILD_CLIENT "Build a command line clFFT client program with a variety of configurable parameters (dependency on Boost)" OFF ) +option( CLFFT_BUILD_TEST "Build the library testing suite (dependency on google test, Boost, and FFTW)" OFF ) +option( CLFFT_BUILD_LOADLIBRARIES "Build the optional dynamic load libraries that the FFT runtime will search for" ON ) +option( BUILD_SHARED_LIBS "Build shared libraries." ON) +option( CLFFT_BUILD_EXAMPLES "Build examples." OFF ) +option( CLFFT_BUILD_CALLBACK_CLIENT "Build a command line clFFT client program that tests callback functionality (dependency on Boost)" OFF ) # If BOOST_ROOT is defined as an environment value, use that value and cache it so it's visible in the cmake-gui. # Otherwise, create a sensible default that the user can change @@ -83,24 +63,24 @@ endif( ) # Currently, linux has a problem outputing both narrow and wide characters, # which happens in our client because openCL only supports narrow characters if( WIN32 ) - option( UNICODE "Build with Unicode Support" ON ) - if( UNICODE ) + option( CLFFT_UNICODE "Build with Unicode Support" ON ) + if( CLFFT_UNICODE ) message( STATUS "UNICODE build" ) endif( ) else( ) - set( UNICODE OFF ) + set( CLFFT_UNICODE OFF ) message( STATUS "UNICODE feature disabled on linux" ) endif() if( MSVC_IDE ) set_property( GLOBAL PROPERTY USE_FOLDERS TRUE ) - set( BUILD64 ${CMAKE_CL_64} ) + set( CLFFT_BUILD64 ${CMAKE_CL_64} ) else() - option( BUILD64 "Build a 64-bit product" ON ) + option( CLFFT_BUILD64 "Build a 64-bit product" ON ) if( IS_DIRECTORY ${PROJECT_SOURCE_DIR}/tests ) - option( CODE_COVERAGE "Build makefiles with code coverage instrumentation" OFF ) - if( CODE_COVERAGE ) + option( CLFFT_CODE_COVERAGE "Build makefiles with code coverage instrumentation" OFF ) + if( CLFFT_CODE_COVERAGE ) message( STATUS "Code coverage instrumentation on" ) endif() endif() @@ -108,24 +88,24 @@ endif() # These variables are meant to contain string which should be appended to the installation paths # of library and executable binaries, respectively. They are meant to be user configurable/overridable. -set( SUFFIX_LIB_DEFAULT "" ) -set( SUFFIX_BIN_DEFAULT "" ) +set( CLFFT_SUFFIX_LIB_DEFAULT "" ) +set( CLFFT_SUFFIX_BIN_DEFAULT "" ) # Modify the global find property to help us find libraries like Boost in the correct paths for 64-bit # Essentially, find_library calls will look for /lib64 instead of /lib; works for windows and linux -if( BUILD64 ) +if( CLFFT_BUILD64 ) set_property( GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE ) message( STATUS "64bit build - FIND_LIBRARY_USE_LIB64_PATHS TRUE" ) - if( NOT APPLE ) - set( SUFFIX_LIB_DEFAULT "64" ) + if( NOT APPLE ) + set( CLFFT_SUFFIX_LIB_DEFAULT "64" ) endif() else( ) set_property( GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE ) message( STATUS "32bit build - FIND_LIBRARY_USE_LIB64_PATHS FALSE" ) endif( ) -set( SUFFIX_LIB ${SUFFIX_LIB_DEFAULT} CACHE STRING "String to append to 'lib' install path" ) -set( SUFFIX_BIN ${SUFFIX_BIN_DEFAULT} CACHE STRING "String to append to 'bin' install path" ) +set( CLFFT_SUFFIX_LIB ${CLFFT_SUFFIX_LIB_DEFAULT} CACHE STRING "String to append to 'lib' install path" ) +set( CLFFT_SUFFIX_BIN ${CLFFT_SUFFIX_BIN_DEFAULT} CACHE STRING "String to append to 'bin' install path" ) # Useful variables to configure FindBoost.cake # set( Boost_USE_MULTITHREADED ON ) @@ -151,14 +131,14 @@ else( ) message( WARNING "Try setting Boost_DEBUG and Boost_DETAILED_FAILURE_MSG for more information" ) endif( ) -# This will define OPENCL_FOUND +# This will define OpenCL_FOUND find_package( OpenCL ) # This will define FFTW_FOUND find_package( FFTW ) # Enable building of the clACML client if both requested and all dependencies are found -if( BUILD_CLIENT AND Boost_FOUND ) +if( CLFFT_BUILD_CLIENT AND Boost_FOUND ) set( FFT_CLIENT ON ) else( ) set( FFT_CLIENT OFF ) @@ -166,7 +146,7 @@ endif( ) # Enable building of the googletest unit test framework if requested and all dependencies are found set( UNIT_TEST OFF ) -if( BUILD_TEST ) +if( CLFFT_BUILD_TEST ) include(gtest.cmake) if( GTEST_FOUND AND Boost_FOUND AND FFTW_FOUND ) set( UNIT_TEST ON ) @@ -176,7 +156,7 @@ if( BUILD_TEST ) endif( ) # Enable building of the callback client if requested and all dependencies are found -if( BUILD_CALLBACK_CLIENT AND Boost_FOUND AND FFTW_FOUND ) +if( CLFFT_BUILD_CALLBACK_CLIENT AND Boost_FOUND AND FFTW_FOUND ) set( FFT_CALLBACK_CLIENT ON ) else( ) set( FFT_CALLBACK_CLIENT OFF ) @@ -219,7 +199,7 @@ elseif( CMAKE_COMPILER_IS_GNUCXX ) add_definitions( "/D_DEBUG" ) endif( ) - if( BUILD64 ) + if( CLFFT_BUILD64 ) set( CMAKE_CXX_FLAGS "-m64 ${CMAKE_CXX_FLAGS}" ) set( CMAKE_C_FLAGS "-m64 ${CMAKE_C_FLAGS}" ) else( ) @@ -227,14 +207,14 @@ elseif( CMAKE_COMPILER_IS_GNUCXX ) set( CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}" ) endif( ) - if( CODE_COVERAGE ) + if( CLFFT_CODE_COVERAGE ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" ) endif( ) endif( ) # If UNICODE is defined for microsoft compilers, pass extra definitions -if( MSVC AND UNICODE ) +if( MSVC AND CLFFT_UNICODE ) add_definitions( "/DUNICODE /D_UNICODE" ) endif( ) @@ -259,7 +239,7 @@ install( FILES "./include" ) # Recurse into subdirectory and start building files there -if( BUILD_RUNTIME AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/library" ) +if( CLFFT_BUILD_RUNTIME AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/library" ) add_subdirectory( library ) else( ) message( "Runtime library will NOT be built" ) @@ -277,7 +257,7 @@ else( ) endif( ) # Recurse into subdirectory and start building files there -if( BUILD_LOADLIBRARIES AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/statTimer" ) +if( CLFFT_BUILD_LOADLIBRARIES AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/statTimer" ) add_subdirectory( statTimer ) else( ) message( "LoadLibraries will NOT be built" ) @@ -297,14 +277,14 @@ else( ) message( "FFT callback client will NOT be built" ) endif( ) -if( BUILD_EXAMPLES ) +if( CLFFT_BUILD_EXAMPLES ) add_subdirectory( examples ) endif( ) if( WIN32 ) set( destdir CMake ) else( ) - set( destdir lib${SUFFIX_LIB}/cmake/clFFT ) + set( destdir lib${CLFFT_SUFFIX_LIB}/cmake/clFFT ) endif( ) string( REGEX REPLACE "[^/]+" ".." reldir "${destdir}" ) configure_file( @@ -329,20 +309,23 @@ else( ) set( CPACK_GENERATOR "TGZ" ) endif( ) -if( BUILD64 ) - set( CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CLFFT_VERSION}-${CMAKE_HOST_SYSTEM_NAME}-x64" ) +if( CLFFT_BUILD64 ) + set( CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${clFFT_VERSION}-${CMAKE_HOST_SYSTEM_NAME}-x64" ) else( ) - set( CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CLFFT_VERSION}-${CMAKE_HOST_SYSTEM_NAME}-x32" ) + set( CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${clFFT_VERSION}-${CMAKE_HOST_SYSTEM_NAME}-x32" ) endif( ) -set( CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CLFFT_VERSION}-${CMAKE_HOST_SYSTEM_NAME}-Source" ) +set( CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${clFFT_VERSION}-${CMAKE_HOST_SYSTEM_NAME}-Source" ) -set( CPACK_PACKAGE_VERSION_MAJOR ${CLFFT_VERSION_MAJOR} ) -set( CPACK_PACKAGE_VERSION_MINOR ${CLFFT_VERSION_MINOR} ) -set( CPACK_PACKAGE_VERSION_PATCH ${CLFFT_VERSION_PATCH} ) +set( CPACK_PACKAGE_VERSION_MAJOR ${clFFT_VERSION_MAJOR} ) +set( CPACK_PACKAGE_VERSION_MINOR ${clFFT_VERSION_MINOR} ) +set( CPACK_PACKAGE_VERSION_PATCH ${clFFT_VERSION_PATCH} ) set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenCL implementation of an FFT library" ) set( CPACK_PACKAGE_VENDOR "Neutral" ) set( CPACK_SOURCE_IGNORE_FILES "/\\\\.hg/;/\\\\.svn/;/\\\\.git/" ) # Define all variables that influence CPack before including CPack, such as install targets include( CPack ) + +# reset cmake module path to any earlier path +set(CMAKE_MODULE_PATH ${old_module_path}) diff --git a/src/FindOpenCL.cmake b/src/FindOpenCL.cmake index ca83e5f8..945781c4 100644 --- a/src/FindOpenCL.cmake +++ b/src/FindOpenCL.cmake @@ -20,7 +20,7 @@ # # Defines the following variables: # -# OPENCL_FOUND - Found the OPENCL framework +# OpenCL_FOUND - Found the OPENCL framework # OPENCL_INCLUDE_DIRS - Include directories # # Also defines the library variables below as normal @@ -97,8 +97,8 @@ endif( ) mark_as_advanced( OPENCL_LIBRARIES ) include( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( OPENCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( OpenCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS ) -if( NOT OPENCL_FOUND ) +if( NOT OpenCL_FOUND ) message( STATUS "FindOpenCL looked for libraries named: OpenCL" ) endif() diff --git a/src/callback-client/CMakeLists.txt b/src/callback-client/CMakeLists.txt index 3167b87e..5e9b335c 100644 --- a/src/callback-client/CMakeLists.txt +++ b/src/callback-client/CMakeLists.txt @@ -47,15 +47,15 @@ add_executable( clFFT-callback-client ${Client.Files} ) target_link_libraries( clFFT-callback-client clFFT ${Boost_LIBRARIES} ${OPENCL_LIBRARIES} ${FFTW_LIBRARIES} ${DL_LIB} ) -set_target_properties( clFFT-callback-client PROPERTIES VERSION ${CLFFT_VERSION} ) +set_target_properties( clFFT-callback-client PROPERTIES VERSION ${clFFT_VERSION} ) set_target_properties( clFFT-callback-client PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging" ) if( APPLE ) # properly deal with RPATH on mac - set_target_properties( clFFT-callback-client PROPERTIES INSTALL_RPATH "@loader_path/../lib${SUFFIX_LIB}") + set_target_properties( clFFT-callback-client PROPERTIES INSTALL_RPATH "@loader_path/../lib${CLFFT_SUFFIX_LIB}") endif() install( TARGETS clFFT-callback-client - RUNTIME DESTINATION bin${SUFFIX_BIN} - LIBRARY DESTINATION lib${SUFFIX_LIB} - ARCHIVE DESTINATION lib${SUFFIX_LIB}/import + RUNTIME DESTINATION bin${CLFFT_SUFFIX_BIN} + LIBRARY DESTINATION lib${CLFFT_SUFFIX_LIB} + ARCHIVE DESTINATION lib${CLFFT_SUFFIX_LIB}/import ) diff --git a/src/clFFTConfigVersion.cmake.in b/src/clFFTConfigVersion.cmake.in index e358473a..937ad092 100644 --- a/src/clFFTConfigVersion.cmake.in +++ b/src/clFFTConfigVersion.cmake.in @@ -6,22 +6,14 @@ # the requested version string are exactly the same and it sets # PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, # but only if the requested major version is the same as the current one. -# The variable CLFFT_VERSION must be set before calling configure_file(). -set(PACKAGE_VERSION "@CLFFT_VERSION@") +set(PACKAGE_VERSION "@clFFT_VERSION@") if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) set(PACKAGE_VERSION_COMPATIBLE FALSE) else() - - if("@CLFFT_VERSION@" MATCHES "^([0-9]+)\\.") - set(CLFFT_VERSION_MAJOR "${CMAKE_MATCH_1}") - else() - set(CLFFT_VERSION_MAJOR "@CLFFT_VERSION@") - endif() - - if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CLFFT_VERSION_MAJOR}") + if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${clFFT_VERSION_MAJOR}") set(PACKAGE_VERSION_COMPATIBLE TRUE) else() set(PACKAGE_VERSION_COMPATIBLE FALSE) @@ -32,7 +24,6 @@ else() endif() endif() - # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") return() diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index db54697e..72a0e560 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -45,15 +45,15 @@ add_executable( clFFT-client ${Client.Files} ) target_link_libraries( clFFT-client clFFT ${Boost_LIBRARIES} ${OPENCL_LIBRARIES} ${CMAKE_DL_LIBS} ${RT_LIB} ) -set_target_properties( clFFT-client PROPERTIES VERSION ${CLFFT_VERSION} ) +set_target_properties( clFFT-client PROPERTIES VERSION ${clFFT_VERSION} ) set_target_properties( clFFT-client PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging" ) if( APPLE ) # properly deal with RPATH on mac - set_target_properties( clFFT-client PROPERTIES INSTALL_RPATH "@loader_path/../lib${SUFFIX_LIB}") + set_target_properties( clFFT-client PROPERTIES INSTALL_RPATH "@loader_path/../lib${CLFFT_SUFFIX_LIB}") endif() install( TARGETS clFFT-client - RUNTIME DESTINATION bin${SUFFIX_BIN} - LIBRARY DESTINATION lib${SUFFIX_LIB} - ARCHIVE DESTINATION lib${SUFFIX_LIB}/import + RUNTIME DESTINATION bin${CLFFT_SUFFIX_BIN} + LIBRARY DESTINATION lib${CLFFT_SUFFIX_LIB} + ARCHIVE DESTINATION lib${CLFFT_SUFFIX_LIB}/import ) diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 0073a345..1683d335 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -21,7 +21,7 @@ INCLUDE_DIRECTORIES( "${PROJECT_BINARY_DIR}/include" ) -LINK_DIRECTORIES("${PROJECT_BINARY_DIR}/package/lib${SUFFIX_LIB}") +LINK_DIRECTORIES("${PROJECT_BINARY_DIR}/package/lib${CLFFT_SUFFIX_LIB}") FILE(GLOB FILES "*.c") diff --git a/src/include/clFFT.version.h.in b/src/include/clFFT.version.h.in index 686f03ea..459fe511 100644 --- a/src/include/clFFT.version.h.in +++ b/src/include/clFFT.version.h.in @@ -17,8 +17,8 @@ /* the configured version and settings for clFFT */ -#define clfftVersionMajor @CLFFT_VERSION_MAJOR@ -#define clfftVersionMinor @CLFFT_VERSION_MINOR@ -#define clfftVersionPatch @CLFFT_VERSION_PATCH@ +#define clfftVersionMajor @clFFT_VERSION_MAJOR@ +#define clfftVersionMinor @clFFT_VERSION_MINOR@ +#define clfftVersionPatch @clFFT_VERSION_PATCH@ #cmakedefine CLFFT_STATIC diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index 132ef86d..5c1a4c6c 100644 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -81,28 +81,37 @@ set( clFFT.Files ${clFFT.Source} ${clFFT.Headers} ) # add_definitions( ${Boost_LIB_DIAGNOSTIC_DEFINITIONS} ) add_definitions( "/DCLFFT_EXPORTS" ) -# Include standard OpenCL headers -include_directories( ${OPENCL_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/include ../include ) - add_library( clFFT ${clFFT.Files} ) + +target_include_directories(clFFT + PUBLIC + $ + $ + $ + ) + target_link_libraries( clFFT ${OPENCL_LIBRARIES} ${CMAKE_DL_LIBS} ) -set_target_properties( clFFT PROPERTIES VERSION ${CLFFT_VERSION} ) -set_target_properties( clFFT PROPERTIES SOVERSION ${CLFFT_SOVERSION} ) -set_target_properties( clFFT PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging" ) +set_target_properties(clFFT PROPERTIES VERSION ${clFFT_VERSION}) +set_target_properties(clFFT PROPERTIES SOVERSION ${clFFT_VERSION_MAJOR}) +set_target_properties(clFFT PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging") + +if(NOT BUILD_SHARED_LIBS) + set_target_properties(clFFT PROPERTIES POSITION_INDEPENDENT_CODE ON) +endif() if( CMAKE_COMPILER_IS_GNUCC ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/clFFT.pc.in ${CMAKE_CURRENT_BINARY_DIR}/clFFT.pc @ONLY ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/clFFT.pc - DESTINATION lib${SUFFIX_LIB}/pkgconfig ) + DESTINATION lib${CLFFT_SUFFIX_LIB}/pkgconfig ) endif( ) # CPack configuration; include the executable into the package install( TARGETS clFFT EXPORT Library - RUNTIME DESTINATION bin${SUFFIX_BIN} - LIBRARY DESTINATION lib${SUFFIX_LIB} - ARCHIVE DESTINATION lib${SUFFIX_LIB}/import + RUNTIME DESTINATION bin${CLFFT_SUFFIX_BIN} + LIBRARY DESTINATION lib${CLFFT_SUFFIX_LIB} + ARCHIVE DESTINATION lib${CLFFT_SUFFIX_LIB}/import ) diff --git a/src/library/clFFT.pc.in b/src/library/clFFT.pc.in index 63dc0ea6..5c8c4a71 100644 --- a/src/library/clFFT.pc.in +++ b/src/library/clFFT.pc.in @@ -1,11 +1,11 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix}/bin@SUFFIX_BIN@ +exec_prefix=${prefix}/bin@CLFFT_SUFFIX_BIN@ includedir=${prefix}/include -libdir=${prefix}/lib@SUFFIX_LIB@ +libdir=${prefix}/lib@CLFFT_SUFFIX_LIB@ Name: clFFT Description: Open source OpenCL FFT library -Version: @CLFFT_VERSION@ +Version: @clFFT_VERSION@ URL: https://github.com/clMathLibraries/clFFT Cflags: -I${includedir} diff --git a/src/scripts/perf/CMakeLists.txt b/src/scripts/perf/CMakeLists.txt index 04831be1..7b05a2f5 100644 --- a/src/scripts/perf/CMakeLists.txt +++ b/src/scripts/perf/CMakeLists.txt @@ -21,7 +21,7 @@ set(GRAPHING_SCRIPTS measurePerformance.py performanceUtility.py ) # if( WIN32 ) -# install( FILES ${GRAPHING_SCRIPTS} DESTINATION bin${SUFFIX_BIN} ) +# install( FILES ${GRAPHING_SCRIPTS} DESTINATION bin${CLFFT_SUFFIX_BIN} ) # else ( ) # install( FILES ${GRAPHING_SCRIPTS} DESTINATION share/clFFT ) # endif( ) diff --git a/src/statTimer/CMakeLists.txt b/src/statTimer/CMakeLists.txt index ffaed11c..6d1bb785 100644 --- a/src/statTimer/CMakeLists.txt +++ b/src/statTimer/CMakeLists.txt @@ -63,11 +63,11 @@ add_definitions( "/DSTATTIMER_EXPORTS" ) # Include standard OpenCL headers include_directories( ${OPENCL_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/include ../include ) -add_library( StatTimer ${StatTimer.Files} ) -set_target_properties( StatTimer PROPERTIES VERSION ${CLFFT_VERSION} ) -set_target_properties( StatTimer PROPERTIES SOVERSION ${CLFFT_SOVERSION} ) -set_target_properties( StatTimer PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging" ) -target_link_libraries( StatTimer ${OPENCL_LIBRARIES} ) +add_library(StatTimer ${StatTimer.Files}) +set_target_properties(StatTimer PROPERTIES VERSION ${clFFT_VERSION}) +set_target_properties(StatTimer PROPERTIES SOVERSION ${clFFT_VERSION_MAJOR}) +set_target_properties(StatTimer PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging") +target_link_libraries(StatTimer ${OPENCL_LIBRARIES}) if( UNIX AND NOT APPLE ) # This library dependency is brought in by the high precision timer available in linux @@ -77,7 +77,7 @@ endif( ) # CPack configuration; include the executable into the package install( TARGETS StatTimer EXPORT Library - RUNTIME DESTINATION bin${SUFFIX_BIN} - LIBRARY DESTINATION lib${SUFFIX_LIB} - ARCHIVE DESTINATION lib${SUFFIX_LIB}/import + RUNTIME DESTINATION bin${CLFFT_SUFFIX_BIN} + LIBRARY DESTINATION lib${CLFFT_SUFFIX_LIB} + ARCHIVE DESTINATION lib${CLFFT_SUFFIX_LIB}/import ) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index c1949727..992f8a0d 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -76,7 +76,7 @@ include_directories( ${Boost_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS} ${FFTW_INCLUDE_ add_executable( Test ${clFFT.Test.Files} ) # If the runtime is being built by the project, use it, otherwise link to a runtime library specified in the install prefix -if( BUILD_RUNTIME ) +if( CLFFT_BUILD_RUNTIME ) target_link_libraries( Test clFFT ${Boost_LIBRARIES} ${GTEST_LIBRARIES} ${FFTW_LIBRARIES} ${OPENCL_LIBRARIES} ${LD_PTHREAD} ${CMAKE_DL_LIBS}) else( ) # Search for 64bit libs if FIND_LIBRARY_USE_LIB64_PATHS is set to true in the global environment, 32bit libs else @@ -103,6 +103,6 @@ IF( (MSVC_VERSION VERSION_EQUAL 1600) AND (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_ set_target_properties( Test PROPERTIES OUTPUT_NAME "clFFT_Test" ) ENDIF( ) -set_target_properties( Test PROPERTIES VERSION ${CLFFT_VERSION} ) +set_target_properties( Test PROPERTIES VERSION ${clFFT_VERSION} ) set_target_properties( Test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging" ) diff --git a/src/tests/copyTestDependencies.cmake.in b/src/tests/copyTestDependencies.cmake.in index 9397bcf4..c63f6b09 100644 --- a/src/tests/copyTestDependencies.cmake.in +++ b/src/tests/copyTestDependencies.cmake.in @@ -23,9 +23,9 @@ get_filename_component( testDir "${fixedTestLocation}" PATH ) set( installPath "" ) if( WIN32 ) - set( installPath "${CMAKE_INSTALL_PREFIX}/bin@SUFFIX_BIN@" ) + set( installPath "${CMAKE_INSTALL_PREFIX}/bin@CLFFT_SUFFIX_BIN@" ) else( ) - set( installPath "${CMAKE_INSTALL_PREFIX}/lib@SUFFIX_LIB@" ) + set( installPath "${CMAKE_INSTALL_PREFIX}/lib@CLFFT_SUFFIX_LIB@" ) endif( ) # Only search for dependencies that have ROOT defined From 2cbdaf0ab0977c1fc06c88d47228d7d57d00cf50 Mon Sep 17 00:00:00 2001 From: pradeep Date: Thu, 3 Dec 2020 12:05:22 +0530 Subject: [PATCH 07/14] Include OpenCL include dir in library include paths --- src/library/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index 5c1a4c6c..152fe7d8 100644 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -88,6 +88,8 @@ target_include_directories(clFFT $ $ $ + PRIVATE + ${OPENCL_INCLUDE_DIRS} ) target_link_libraries( clFFT ${OPENCL_LIBRARIES} ${CMAKE_DL_LIBS} ) From 385d4b84fbe3217ad73f581cd5390b8de085bc7d Mon Sep 17 00:00:00 2001 From: Pradeep Garigipati Date: Fri, 22 Jan 2021 20:10:56 +0530 Subject: [PATCH 08/14] Fix value to string conversion in transpose code --- src/library/generator.transpose.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/generator.transpose.cpp b/src/library/generator.transpose.cpp index a04a43ae..03cdbe00 100644 --- a/src/library/generator.transpose.cpp +++ b/src/library/generator.transpose.cpp @@ -1089,8 +1089,8 @@ clfftStatus genSwapKernelGeneral(const FFTGeneratedTransposeNonSquareAction::Sig //std::string funcName = "swap_nonsquare_" + std::to_string(smaller_dim) + "_" + std::to_string(dim_ratio); std::string funcName = "swap_nonsquare_"; - std::string smaller_dim_str = static_cast(&(std::ostringstream() << smaller_dim))->str(); - std::string dim_ratio_str = static_cast(&(std::ostringstream() << dim_ratio))->str(); + std::string smaller_dim_str = static_cast(std::ostringstream() << smaller_dim).str(); + std::string dim_ratio_str = static_cast(std::ostringstream() << dim_ratio).str(); if(params.fft_N[0] > params.fft_N[1]) funcName = funcName + smaller_dim_str + "_" + dim_ratio_str; else From 5a1db8c3af850d34cfae8f4ce8f387873ecb8a69 Mon Sep 17 00:00:00 2001 From: pradeep Date: Mon, 22 Feb 2021 19:51:34 +0530 Subject: [PATCH 09/14] Fix 64 bit flag for compiler on Aarch architecture --- src/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ffb8fcdf..9eecbb7d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -200,8 +200,13 @@ elseif( CMAKE_COMPILER_IS_GNUCXX ) endif( ) if( CLFFT_BUILD64 ) - set( CMAKE_CXX_FLAGS "-m64 ${CMAKE_CXX_FLAGS}" ) - set( CMAKE_C_FLAGS "-m64 ${CMAKE_C_FLAGS}" ) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + set( CMAKE_CXX_FLAGS "-march=armv8-a ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-march=armv8-a ${CMAKE_C_FLAGS}" ) + else() + set( CMAKE_CXX_FLAGS "-m64 ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-m64 ${CMAKE_C_FLAGS}" ) + endif() else( ) set( CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}" ) set( CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}" ) From 88f02a8828fef89cca3126889bfacb44817f620c Mon Sep 17 00:00:00 2001 From: pradeep Date: Mon, 15 Mar 2021 16:57:00 +0530 Subject: [PATCH 10/14] Guard CMP0077 policy set command in cmake --- src/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9eecbb7d..aa2bde87 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,9 @@ cmake_minimum_required(VERSION 3.5) -cmake_policy(SET CMP0077 NEW) +if(POLICY CMP007) + cmake_policy(SET CMP0077 NEW) +endif() if(CMAKE_GENERATOR MATCHES "NMake") option(NMAKE_COMPILE_VERBOSE "Print compile and link strings to the console" OFF) From a5ebd7045c66a3df3824331a4dc1e9af950d0bd5 Mon Sep 17 00:00:00 2001 From: pradeep Date: Mon, 22 Mar 2021 19:26:16 +0530 Subject: [PATCH 11/14] Fix a typo in cmake policy check condition --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa2bde87..0c99b968 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.5) -if(POLICY CMP007) +if(POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif() From 760096b37dcc4f18ccd1aac53f3501a83b83449c Mon Sep 17 00:00:00 2001 From: Umar Arshad Date: Fri, 8 Jul 2022 17:26:08 -0400 Subject: [PATCH 12/14] Fix address sanitizer leaks --- src/library/action.h | 8 +++--- src/library/plan.h | 3 +++ src/library/repo.cpp | 6 ++--- src/library/repo.h | 59 +++++++++++++++++++++++++++----------------- 4 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/library/action.h b/src/library/action.h index aecbe587..4bbab9ad 100644 --- a/src/library/action.h +++ b/src/library/action.h @@ -51,6 +51,7 @@ class FFTStockhamAction : public FFTAction FFTStockhamAction(clfftPlanHandle plHandle, FFTPlan * plan, cl_command_queue queue, clfftStatus & err); clfftGenerators getGenerator() { return Stockham; } + virtual ~FFTStockhamAction() = default; }; @@ -178,11 +179,8 @@ class FFTGeneratedStockhamAction : public FFTStockhamAction bool buildBackwardKernel(); public: - - virtual const Signature * getSignatureData() - { - return &this->signature; - } + virtual ~FFTGeneratedStockhamAction() = default; + virtual const Signature *getSignatureData() { return &this->signature; } }; diff --git a/src/library/plan.h b/src/library/plan.h index 8368e5fe..296ec59f 100644 --- a/src/library/plan.h +++ b/src/library/plan.h @@ -364,6 +364,9 @@ class FFTAction virtual bool buildForwardKernel() = 0; virtual bool buildBackwardKernel() = 0; + +public: + virtual ~FFTAction() = default; }; diff --git a/src/library/repo.cpp b/src/library/repo.cpp index 4a668296..48f7876a 100644 --- a/src/library/repo.cpp +++ b/src/library/repo.cpp @@ -138,7 +138,7 @@ clfftStatus FFTRepo::setProgramCode( const clfftGenerators gen, const FFTKernelS std::string prefixCopyright = ss.str(); - mapFFTs[ key ].ProgramString = prefixCopyright + kernel; + mapFFTs[std::move(key)].ProgramString = prefixCopyright + kernel; return CLFFT_SUCCESS; } @@ -210,8 +210,8 @@ clfftStatus FFTRepo::setclProgram( const clfftGenerators gen, const FFTKernelSig if( pos == mapFFTs.end( ) ) { key.privatizeData(); // the key owns the data - mapFFTs[ key ].clProgram = prog; - } + mapFFTs[std::move(key)].clProgram = prog; + } else { cl_program p = pos->second.clProgram; assert (NULL == p); diff --git a/src/library/repo.h b/src/library/repo.h index dfe1e98a..e4cd1c37 100644 --- a/src/library/repo.h +++ b/src/library/repo.h @@ -42,8 +42,21 @@ class FFTRepo clfftGenerators gen; const FFTKernelSignatureHeader * data; cl_context context; - cl_device_id device; - bool dataIsPrivate; + cl_device_id device; + bool dataIsPrivate; + + ~FFTRepoKey() { + if(data) deleteData(); + } + + FFTRepoKey(const FFTRepoKey &other) = default; + + FFTRepoKey(FFTRepoKey && other) + : gen(other.gen), data(other.data), context(other.context), + device(other.device), dataIsPrivate(other.dataIsPrivate) { + other.data = nullptr; + other.dataIsPrivate = false; + } FFTRepoKey(clfftGenerators gen_, const FFTKernelSignatureHeader * data_, cl_context context_, cl_device_id device_) : gen(gen_), data(data_), context(context_), device(device_), dataIsPrivate(false) @@ -56,17 +69,17 @@ class FFTRepo char * tmp = new char[data->datasize]; ::memcpy(tmp, data, data->datasize); this->data = (FFTKernelSignatureHeader*) tmp; - dataIsPrivate = true; + dataIsPrivate = true; } void deleteData() { if ( dataIsPrivate && (this->data != NULL) ) { - char *tmp = (char *)(this->data); - delete[] tmp; - this->data = 0; - } + char *tmp = (char *)(this->data); + delete[] tmp; + this->data = 0; + } } bool operator<(const FFTRepoKey & b) const @@ -76,22 +89,17 @@ class FFTRepo if (a.gen != b.gen) { return a.gen < b.gen; - } - else if (a.data->datasize != b.data->datasize) - { - return a.data->datasize < b.data->datasize; - } - else if (a.context != b.context) - { - return a.context < b.context; - } - else if (a.device != b.device) - { - return a.device < b.device; - } - else - { - return ::memcmp(a.data, b.data, a.data->datasize) < 0; + } else if ((a.data && b.data) && + a.data->datasize != b.data->datasize) { + return a.data->datasize < b.data->datasize; + } else if (a.context != b.context) { + return a.context < b.context; + } else if (a.device != b.device) { + return a.device < b.device; + } else if(a.data && b.data){ + return ::memcmp(a.data, b.data, a.data->datasize) < 0; + } else { + return false; } } }; @@ -133,6 +141,11 @@ class FFTRepo , kernel_fwd_lock(NULL) , kernel_back_lock(NULL) {} + + ~fftKernels() { + if(kernel_fwd_lock) delete kernel_fwd_lock; + if (kernel_back_lock) delete kernel_back_lock; + } }; typedef std::map< cl_program, fftKernels > mapKernelType; From dabd60b0fe497fa45281a33966efcd8b8dd3035e Mon Sep 17 00:00:00 2001 From: Christophe Murphy Date: Thu, 5 Dec 2024 09:51:37 -0800 Subject: [PATCH 13/14] Remove use of deprecated unary_function which is causing build issues with Visual Studio 2022 / MSVC v144 --- src/statTimer/statisticalTimer.CPU.cpp | 2 +- src/statTimer/statisticalTimer.GPU.cpp | 2 +- src/statTimer/statisticalTimer.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/statTimer/statisticalTimer.CPU.cpp b/src/statTimer/statisticalTimer.CPU.cpp index 4e3c8c2e..d4f1c604 100644 --- a/src/statTimer/statisticalTimer.CPU.cpp +++ b/src/statTimer/statisticalTimer.CPU.cpp @@ -62,7 +62,7 @@ std::basic_string commatize (T number) // Functor object to help with accumulating values in vectors template< typename T > -struct Accumulator: public std::unary_function< T, void > +struct Accumulator { T acc; diff --git a/src/statTimer/statisticalTimer.GPU.cpp b/src/statTimer/statisticalTimer.GPU.cpp index 403178ef..6f06f358 100644 --- a/src/statTimer/statisticalTimer.GPU.cpp +++ b/src/statTimer/statisticalTimer.GPU.cpp @@ -54,7 +54,7 @@ std::basic_string commatize (T number) // Functor object to help with accumulating values in vectors template< typename T > -struct Accumulator: public std::unary_function< T, void > +struct Accumulator { T acc; diff --git a/src/statTimer/statisticalTimer.h b/src/statTimer/statisticalTimer.h index 58c03b70..65b0c1b3 100644 --- a/src/statTimer/statisticalTimer.h +++ b/src/statTimer/statisticalTimer.h @@ -35,11 +35,11 @@ // Definition of a functor object that is passed by reference into the Print statement // of the timing class. // Functor object to help with accumulating values in vectors -template< typename A, typename R > -class flopsFunc: public std::unary_function< A, R > +template +class flopsFunc { public: - virtual typename std::unary_function::result_type operator( )( ) = 0; + virtual R operator( )( ) = 0; }; /** From 2afcde33550523d40d1405155406fe2d956231f5 Mon Sep 17 00:00:00 2001 From: Christophe Murphy Date: Thu, 12 Dec 2024 10:49:59 -0800 Subject: [PATCH 14/14] Replace deprecated std::unary_function with std::function --- src/statTimer/statisticalTimer.CPU.cpp | 2 +- src/statTimer/statisticalTimer.GPU.cpp | 2 +- src/statTimer/statisticalTimer.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/statTimer/statisticalTimer.CPU.cpp b/src/statTimer/statisticalTimer.CPU.cpp index d4f1c604..7939ef5a 100644 --- a/src/statTimer/statisticalTimer.CPU.cpp +++ b/src/statTimer/statisticalTimer.CPU.cpp @@ -62,7 +62,7 @@ std::basic_string commatize (T number) // Functor object to help with accumulating values in vectors template< typename T > -struct Accumulator +struct Accumulator: public std::function { T acc; diff --git a/src/statTimer/statisticalTimer.GPU.cpp b/src/statTimer/statisticalTimer.GPU.cpp index 6f06f358..ac307d6d 100644 --- a/src/statTimer/statisticalTimer.GPU.cpp +++ b/src/statTimer/statisticalTimer.GPU.cpp @@ -54,7 +54,7 @@ std::basic_string commatize (T number) // Functor object to help with accumulating values in vectors template< typename T > -struct Accumulator +struct Accumulator: public std::function { T acc; diff --git a/src/statTimer/statisticalTimer.h b/src/statTimer/statisticalTimer.h index 65b0c1b3..643e5a01 100644 --- a/src/statTimer/statisticalTimer.h +++ b/src/statTimer/statisticalTimer.h @@ -35,11 +35,11 @@ // Definition of a functor object that is passed by reference into the Print statement // of the timing class. // Functor object to help with accumulating values in vectors -template -class flopsFunc +template +class flopsFunc: public std::function { public: - virtual R operator( )( ) = 0; + virtual typename std::function::result_type operator( )( ) = 0; }; /**