From 3288bb7601fe7cc0068367c4e13f9e7924e170a6 Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Tue, 3 Aug 2021 12:17:53 -0700 Subject: [PATCH 01/11] updated 7z command in create package --- package/create_package.sh | 188 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100755 package/create_package.sh diff --git a/package/create_package.sh b/package/create_package.sh new file mode 100755 index 00000000..28560c6a --- /dev/null +++ b/package/create_package.sh @@ -0,0 +1,188 @@ +#!/bin/bash +args=("$@") + +# be wary of /i /s /q :: -n? (-s is subfolders?) (-q is no confirmation) + +set +v +# create package for Gpufit, assumes everything is compiled + +if [[ -z $1 ]]; +then + echo specify build base path + exit 3 +fi + + +if [[ -z $2 ]]; +then + echo specify version + exit 3 +fi + + +if [[ -z $3 ]]; +then + echo specify source base path + exit 3 +fi + + +# define paths + +export BUILD_BASE=${args[0]} +export VERSION=${args[1]} +export SOURCE_BASE=${args[2]} + +export OUTPUT_NAME=Gpufit_$VERSION +export ROOT_INSTALL=$BUILD_BASE/install +export PACKAGE_INSTALL=$BUILD_BASE/install/$OUTPUT_NAME +export OUTPUT_ZIP=$ROOT_INSTALL/${OUTPUT_NAME}_linux.zip +export OUTPUT_DEB=$ROOT_INSTALL/${OUTPUT_NAME}.deb + +export PERFORMANCE_TEST_INSTALL=$PACKAGE_INSTALL/gpufit_performance_test +export PYTHON_INSTALL=$PACKAGE_INSTALL/PYTHON +export x64_MATLAB_INSTALL=$PACKAGE_INSTALL/matlab64 +export x64_JAVA_INSTALL=$PACKAGE_INSTALL/java64 +export SDK_INSTALL_ROOT=$PACKAGE_INSTALL/gpufit_sdk +export DEB_ROOT=$PACKAGE_INSTALL + +export x64_BUILD=$BUILD_BASE +#export x64_BUILD_LIB=$BUILD_BASE/Gpufit + + +export x64_PYTHON_BUILD=$x64_BUILD/pyGpufit/dist + +export x64_MATLAB_BUILD=$x64_BUILD/matlab + +export x64_JAVA_BUILD=$x64_BUILD/java + +export EXAMPLES_SOURCE=$SOURCE_BASE/examples +export PYTHON_SOURCE=$SOURCE_BASE/Gpufit/python +export MATLAB_SOURCE=$SOURCE_BASE/Gpufit/matlab +export SDK_README_SOURCE=$SOURCE_BASE/package/sdk_readme.txt + +export MANUAL_SOURCE=$SOURCE_BASE/docs/_build/latex/Gpufit.pdf +export MANUAL_INSTALL=$PACKAGE_INSTALL/Gpufit_VERSION_Manual.pdf + +# clean up (if necessary) + +if [[ -e "$ROOT_INSTALL" ]]; +then + rm -r "$ROOT_INSTALL" +fi +#if [[ -e "$OUTPUT_ZIP" ]]; +#then +# rm "$OUTPUT_ZIP" +#fi +#if [[ -e "$OUTPUT_DEB" ]]; +#then +# rm "$OUTPUT_DEB" +#fi + +# create root folder + +echo create root directory +mkdir $ROOT_INSTALL +mkdir $PACKAGE_INSTALL + +# create .deb package +echo collect .deb files +mkdir $DEB_ROOT/DEBIAN +cp "$SOURCE_BASE/package/control" "$DEB_ROOT/DEBIAN" +sed -i "s/version_string/${VERSION}/" $DEB_ROOT/DEBIAN/control + +mkdir $DEB_ROOT/usr +mkdir $DEB_ROOT/usr/local +mkdir $DEB_ROOT/usr/lib +cp "$x64_BUILD/Gpufit/libGpufit.so" "$DEB_ROOT/usr/lib" +cp "$x64_BUILD/Cpufit/libCpufit.so" "$DEB_ROOT/usr/lib" + +mkdir $DEB_ROOT/usr/local/include +cp "$SOURCE_BASE/Gpufit/gpufit.h" "$DEB_ROOT/usr/local/include" + +mkdir $DEB_ROOT/usr/local/bin +cp "$x64_BUILD/Gpufit_Cpufit_Performance_Comparison" "$DEB_ROOT/usr/local/bin" + +echo creating .deb +(cd ${DEB_ROOT}/.. && dpkg-deb --build $OUTPUT_NAME) + +echo delete temp files +rm -r $DEB_ROOT +mkdir $PACKAGE_INSTALL +mv ${OUTPUT_DEB} ${PACKAGE_INSTALL} + +# copy main readme (is markdown, written as txt) and license. + +cp "$SOURCE_BASE/README.md" "$PACKAGE_INSTALL/README.txt" +cp "$SOURCE_BASE/LICENSE.txt" "$PACKAGE_INSTALL" + +# copy manual + +#if [[ ! -e "$MANUAL_SOURCE" ]]; +#then +# echo file $MANUAL_SOURCE required, does not exist +# exit 3 +#fi +# +#cp "$MANUAL_SOURCE" "$MANUAL_INSTALL" + +# copy performance test + +echo collect performance test application +mkdir $PERFORMANCE_TEST_INSTALL +cp "$EXAMPLES_SOURCE/Gpufit_Cpufit_Performance_Comparison_readme.txt" "$PERFORMANCE_TEST_INSTALL/README.txt" + +mkdir $PERFORMANCE_TEST_INSTALL/linux +cp "$x64_BUILD/Gpufit_Cpufit_Performance_Comparison" "$PERFORMANCE_TEST_INSTALL/linux" +cp "$x64_BUILD/Gpufit/libGpufit.so" "$PERFORMANCE_TEST_INSTALL/linux" +cp "$x64_BUILD/Cpufit/libCpufit.so" "$PERFORMANCE_TEST_INSTALL/linux" + + +# copy Python packages + +echo collect python +mkdir $PYTHON_INSTALL +cp "$x64_PYTHON_BUILD/pyGpufit-$VERSION-py2.py3-none-any.whl" "$PYTHON_INSTALL/pyGpufit-$VERSION-py2.py3-none-any.whl" +cp "$PYTHON_SOURCE/README.txt" "$PYTHON_INSTALL" +cp "$PYTHON_SOURCE/examples" "$PYTHON_INSTALL/examples" -n -r + + +# copy Matlab 64 bit + +echo collect matlab64 +mkdir $x64_MATLAB_INSTALL +cp "$x64_MATLAB_BUILD" "$x64_MATLAB_INSTALL" -r +cp "$MATLAB_SOURCE/examples" "$x64_MATLAB_INSTALL/examples" -n -r + + +# copy Java 64 bit + +echo collect java64 +mkdir $x64_JAVA_INSTALL +cp "$x64_JAVA_BUILD" "$x64_JAVA_INSTALL" -r + + +# copy SDK_INSTALL_ROOT + +echo collect SDK +mkdir $SDK_INSTALL_ROOT +cp "$SDK_README_SOURCE" "$SDK_INSTALL_ROOT/README.txt" + +mkdir $SDK_INSTALL_ROOT/include +cp "$SOURCE_BASE/Gpufit/gpufit.h" "$SDK_INSTALL_ROOT/include" + +mkdir $SDK_INSTALL_ROOT/linux +cp "$x64_BUILD/Gpufit/libGpufit.so" "$SDK_INSTALL_ROOT/linux" +#cp "$x64_BUILD_LIB/Gpufit.a" "$SDK_INSTALL_ROOT/linux" + + +# zip content of temp folder with 7-Zip if available +if 7z a -bso0 "${OUTPUT_ZIP}" "${PACKAGE_INSTALL}" +then + #it worked + echo Created ${OUTPUT_ZIP} +else + echo Packing ${OUTPUT_ZIP} failed +fi + + From 90383194f97b693c2ffd35faac1df77eb5004fb0 Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Thu, 11 Jul 2019 11:32:38 -0700 Subject: [PATCH 02/11] Fixed CUBLAS linking on linux, static and dynamic --- Gpufit/CMakeLists.txt | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Gpufit/CMakeLists.txt b/Gpufit/CMakeLists.txt index e1d5d2d5..ef5a08ff 100644 --- a/Gpufit/CMakeLists.txt +++ b/Gpufit/CMakeLists.txt @@ -194,15 +194,29 @@ if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND CUDA_VERSION VERSION_GREATER "6.5") add_custom_command( TARGET Gpufit POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CUBLAS_DLL} $ ) + target_link_libraries( Gpufit ${CUDA_CUBLAS_LIBRARIES} ) else() - set( CUDA_CUBLAS_LIBRARIES - ${CUDA_TOOLKIT_ROOT_DIR}/lib64/libcublas_static.a - ${CUDA_TOOLKIT_ROOT_DIR}/lib64/libculibos.a ) - endif() - + set( STATIC_CUBLAS ON CACHE BOOL "ON | OFF") + if ( STATIC_CUBLAS ) + find_cuda_helper_libs(cublas_static) + find_cuda_helper_libs(cublasLt_static) + find_cuda_helper_libs(culibos) + + set( CUDA_CUBLAS_LIBRARIES + ${CUDA_cublas_static_LIBRARY} + ${CUDA_cublasLt_static_LIBRARY} + ${CUDA_cudart_static_LIBRARY} + ${CUDA_culibos_LIBRARY} + dl + pthread + rt ) + target_link_libraries( Gpufit ${CUDA_CUBLAS_LIBRARIES} ) + else () + # Dynamic Link can be done with a single function call + CUDA_ADD_CUBLAS_TO_TARGET( Gpufit ) + endif () + endif() add_definitions( -DUSE_CUBLAS ) - - target_link_libraries( Gpufit ${CUDA_CUBLAS_LIBRARIES} ) endif() elseif( CMAKE_SIZEOF_VOID_P EQUAL 4 ) message( STATUS "CUBLAS: 32-bit architecture detected; USE_CUBLAS flag ignored." ) From 5787df2ff96842a804f6fec42f1b5f00ac94f486 Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Tue, 10 Aug 2021 11:11:20 -0700 Subject: [PATCH 03/11] Added scripts for binary release, install, and testing in linux --- Gpufit/tests/CMakeLists.txt | 8 ++++++++ Gpufit/tests/test_all.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 Gpufit/tests/test_all.sh diff --git a/Gpufit/tests/CMakeLists.txt b/Gpufit/tests/CMakeLists.txt index 2f037499..cd31a990 100644 --- a/Gpufit/tests/CMakeLists.txt +++ b/Gpufit/tests/CMakeLists.txt @@ -10,3 +10,11 @@ add_boost_test( Gpufit Gauss_Fit_2D_Rotated ) add_boost_test( Gpufit Cauchy_Fit_2D_Elliptic ) add_boost_test( Gpufit Fletcher_Powell_Helix_Fit ) add_boost_test( Gpufit Brown_Dennis_Fit ) + +if( UNIX ) + # Copy over run tests script + file(COPY "${CMAKE_SOURCE_DIR}/Gpufit/tests/test_all.sh" + DESTINATION "${CMAKE_BINARY_DIR}" + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) +endif() diff --git a/Gpufit/tests/test_all.sh b/Gpufit/tests/test_all.sh new file mode 100755 index 00000000..640f9058 --- /dev/null +++ b/Gpufit/tests/test_all.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +printf "Gauss 2D Rotated\n" +./Gpufit_Test_Gauss_Fit_2D_Rotated + +printf "\nGauss 2D Elliptic\n" +./Gpufit_Test_Gauss_Fit_2D_Elliptic + +printf "\nGauss 2D\n" +./Gpufit_Test_Gauss_Fit_2D + +printf "\nGauss 1D\n" +./Gpufit_Test_Gauss_Fit_1D + +printf "\nLinear 1D\n" +./Gpufit_Test_Linear_Fit_1D + +printf "\nFletcher Powell Helix\n" +./Gpufit_Test_Fletcher_Powell_Helix_Fit + +printf "\nError Handling\n" +./Gpufit_Test_Error_Handling + +printf "\nCauchy Fit 2D Elliptic\n" +./Gpufit_Test_Cauchy_Fit_2D_Elliptic + +printf "\nBrown Dennis\n" +./Gpufit_Test_Brown_Dennis_Fit + +printf "\nTest Consistency\n" +./Cpufit_Gpufit_Test_Consistency + + + From 14f79f5d45c66db377b6e95c20c2319f8716b5a8 Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Tue, 10 Aug 2021 11:24:37 -0700 Subject: [PATCH 04/11] added linux python install script --- CMakeLists.txt | 7 +++++++ package/install_gpufit_python.sh | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 package/install_gpufit_python.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 898353fd..fb78d781 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,13 @@ if( PYTHONINTERP_FOUND ) "${Python_WORKING_DIRECTORY}" ) endif() + if( UNIX ) + # Copy over install file for python integration + configure_file( "${CMAKE_SOURCE_DIR}/package/install_gpufit_python.sh" + "${CMAKE_BINARY_DIR}/install_gpufit_python.sh" + COPYONLY + ) + endif() endif() # Tests diff --git a/package/install_gpufit_python.sh b/package/install_gpufit_python.sh new file mode 100644 index 00000000..47fe32f7 --- /dev/null +++ b/package/install_gpufit_python.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +pip3 install pyGpufit/dist/pyGpufit-1.1.0-py2.py3-none-any.whl From f283f450b20cdd2da4964bda88f12e786c205f8c Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Tue, 10 Aug 2021 10:59:33 -0700 Subject: [PATCH 05/11] updated file permissions on copy for linux python install --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb78d781..c83065d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,9 +186,9 @@ if( PYTHONINTERP_FOUND ) endif() if( UNIX ) # Copy over install file for python integration - configure_file( "${CMAKE_SOURCE_DIR}/package/install_gpufit_python.sh" - "${CMAKE_BINARY_DIR}/install_gpufit_python.sh" - COPYONLY + file(COPY "${CMAKE_SOURCE_DIR}/package/install_gpufit_python.sh" + DESTINATION "${CMAKE_BINARY_DIR}" + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) endif() endif() From 95b136e8560a096f40b79f57e6403c5fdb9c35eb Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Tue, 10 Aug 2021 11:04:57 -0700 Subject: [PATCH 06/11] updated version in linus python install script --- package/install_gpufit_python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/install_gpufit_python.sh b/package/install_gpufit_python.sh index 47fe32f7..d31584c7 100644 --- a/package/install_gpufit_python.sh +++ b/package/install_gpufit_python.sh @@ -1,3 +1,3 @@ #!/bin/bash -pip3 install pyGpufit/dist/pyGpufit-1.1.0-py2.py3-none-any.whl +pip3 install pyGpufit/dist/pyGpufit-1.2.0-py2.py3-none-any.whl From 8a0f84559877f92a46badab71ad75dd9bacdc985 Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Thu, 12 Aug 2021 14:30:16 -0700 Subject: [PATCH 07/11] use new cmake cuda tools, requires cmake 3.18 replaced depricated FindCuda with new LANGUAGES CUDA simplifies architecture and cublas --- CMakeLists.txt | 2 +- Gpufit/CMakeLists.txt | 179 ++++++++------------------------- Gpufit/examples/CMakeLists.txt | 2 +- 3 files changed, 44 insertions(+), 139 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a33a06c..57457043 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ cmake_minimum_required( VERSION 3.11 ) set_property( GLOBAL PROPERTY USE_FOLDERS ON ) if( NOT PROJECT_NAME ) - project( Gpufit VERSION 1.2.0 ) + project( Gpufit VERSION 1.2.0 LANGUAGES CUDA CXX) include( CTest ) endif() diff --git a/Gpufit/CMakeLists.txt b/Gpufit/CMakeLists.txt index 03572be8..57b108d8 100644 --- a/Gpufit/CMakeLists.txt +++ b/Gpufit/CMakeLists.txt @@ -1,135 +1,61 @@ # CUDA # -# Uses the following variables: -# -# CUDA_ARCHITECTURES (Default All) -# -- Argument passed to CUDA_SELECT_NVCC_ARCH_FLAGS(...) -# resulting in code_generation_flags -# (see http://cmake.org/cmake/help/v3.7/module/FindCUDA.html). -# CUDA_ARCHITECTURES: Auto | Common | All | ARCH_AND_PTX ... -# Auto: Detects local machine GPU architecture. -# Common: Covers common subset of architectures. -# All: Covers all known architectures. -# ARCH_AND_PTX: NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX -# NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal -# NUM: Any number. -# Only those pairs are currently accepted by NVCC though: -# 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 -# Examples: -# 2.1(2.0) results in -# -gencode;arch=compute_20,code=sm_21 -# Kepler+Tesla results in -# -gencode;arch=compute_37,code=sm_37 -# 6.2+PTX results in -# -gencode;arch=compute_62,code=sm_62;-gencode;arch=compute_62,code=compute_62 -# -# CUDA_NVCC_FLAGS (Default ${code_generation_flags}) -# -- Additional NVCC command line arguments -# (see http://cmake.org/cmake/help/v3.7/module/FindCUDA.html). -# NOTE that multiple arguments must be semi-colon delimited -# (e.g. --compiler-options;-Wall) -# -# Multiple CUDA versions installed, specify which version to use -# Set CUDA_BIN_PATH before running CMake or CUDA_TOOLKIT_ROOT_DIR after first configuration -# to installation folder of desired CUDA version - -find_package( CUDA 6.5 REQUIRED ) - -set( CUDA_ARCHITECTURES ${DEFAULT_CUDA_ARCH} CACHE STRING - "Auto | Common | All | ... see CUDA_SELECT_NVCC_ARCH_FLAGS(...)" ) - -if( CUDA_ARCHITECTURES STREQUAL Auto ) - - set( file ${PROJECT_BINARY_DIR}/detect_cuda_architectures.cpp ) - file( WRITE ${file} "" - "#include \n" - "#include \n" - "int main()\n" - "{\n" - " int count = 0;\n" - " if (cudaSuccess != cudaGetDeviceCount(&count)) return -1;\n" - " if (count == 0) return -1;\n" - " for (int device = 0; device < count; ++device)\n" - " {\n" - " cudaDeviceProp prop;\n" - " if (cudaSuccess == cudaGetDeviceProperties(&prop, device))\n" - " std::printf(\"%d.%d \", prop.major, prop.minor);\n" - " }\n" - " return 0;\n" - "}\n" - ) - try_run( run_result compile_result ${PROJECT_BINARY_DIR} ${file} - CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}" - LINK_LIBRARIES ${CUDA_LIBRARIES} - RUN_OUTPUT_VARIABLE architectures - ) - if( run_result EQUAL 0 ) - string( REPLACE "2.1" "2.1(2.0)" architectures "${architectures}" ) - if( CUDA_VERSION VERSION_LESS "7.0" ) - string( REGEX REPLACE "3\\.[27]|5\\.[23]|6\\.[01]" "5.2+PTX" architectures "${architectures}" ) - elseif( CUDA_VERSION VERSION_LESS "8.0" ) - string( REGEX REPLACE "5\\.3|6\\.[01]" "5.3+PTX" architectures "${architectures}" ) - endif() - set( CUDA_ARCHITECTURES "${architectures}" ) - endif() - -elseif( CUDA_ARCHITECTURES STREQUAL All ) +# Uses the CMAKE standard CUDA tools + +cmake_minimum_required(VERSION 3.18) + +if(NOT DEFINED CMAKE_CUDA_STANDARD) + set(CMAKE_CUDA_STANDARD 14) + set(CMAKE_CUDA_STANDARD_REQUIRED ON) +endif() + + +message( STATUS "CMAKE_CUDA_COMPILER_VERSION=${CMAKE_CUDA_COMPILER_VERSION}") + # All does not include the latest PTX! - set( CUDA_ARCHITECTURES "" ) + set( CMAKE_CUDA_ARCHITECTURES_D "" ) - if( CUDA_VERSION VERSION_LESS "12.0" ) - list( INSERT CUDA_ARCHITECTURES 0 "3.5" "5.0" "5.2" ) + if( CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "12.0" ) + list( INSERT CMAKE_CUDA_ARCHITECTURES_D 0 35 50 52 ) endif() - if( CUDA_VERSION VERSION_LESS "11.0" ) - list( INSERT CUDA_ARCHITECTURES 0 "3.0" "3.2") + if( CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "11.0" ) + list( INSERT CMAKE_CUDA_ARCHITECTURES_D 0 30 32) endif() - if( CUDA_VERSION VERSION_LESS "9.0" ) - list( INSERT CUDA_ARCHITECTURES 0 "2.0" "2.1(2.0)" ) + if( CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "9.0" ) + list( INSERT CMAKE_CUDA_ARCHITECTURES_D 0 20 21 ) endif() - - if( CUDA_VERSION VERSION_GREATER "6.5" ) - list( APPEND CUDA_ARCHITECTURES "5.3" ) + + + if( CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER "6.5" ) + list( APPEND CMAKE_CUDA_ARCHITECTURES_D 53 ) endif() - if( CUDA_VERSION VERSION_GREATER "7.5" ) - list( APPEND CUDA_ARCHITECTURES "6.0" "6.1" ) + if( CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER "7.5" ) + list( APPEND CMAKE_CUDA_ARCHITECTURES_D 60 61 ) endif() - if( CUDA_VERSION VERSION_GREATER "8.0" ) - list( APPEND CUDA_ARCHITECTURES "7.0" "7.2") + if( CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER "8.0" ) + list( APPEND CMAKE_CUDA_ARCHITECTURES_D 70 72) endif() - if( CUDA_VERSION VERSION_GREATER "9.2" ) - list( APPEND CUDA_ARCHITECTURES "7.5" ) + if( CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER "9.2" ) + list( APPEND CMAKE_CUDA_ARCHITECTURES_D 75 ) endif() - if( CUDA_VERSION VERSION_GREATER "10.2" ) - list( APPEND CUDA_ARCHITECTURES "8.0" ) + if( CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER "10.2" ) + list( APPEND CMAKE_CUDA_ARCHITECTURES_D 80 ) endif() - if( CUDA_VERSION VERSION_GREATER "11.0" ) - list( APPEND CUDA_ARCHITECTURES "8.6" ) + if( CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER "11.0" ) + list( APPEND CMAKE_CUDA_ARCHITECTURES_D 86 ) endif() - - string( APPEND CUDA_ARCHITECTURES "+PTX" ) - -endif() +# string( APPEND CMAKE_CUDA_ARCHITECTURES "+PTX" ) + set( CMAKE_CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES_D}" CACHE STRING "List of architectures to compile, default is all") -message( STATUS "CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES}" ) - -CUDA_SELECT_NVCC_ARCH_FLAGS( code_generation_flags "${CUDA_ARCHITECTURES}" ) -list( APPEND CUDA_NVCC_FLAGS ${code_generation_flags} ) - -message( STATUS "CUDA_NVCC_FLAGS=${code_generation_flags}" ) - -if( NOT WIN32 ) - list( APPEND CUDA_NVCC_FLAGS --std=c++11) -endif() # Gpufit - set( GpuHeaders gpufit.h constants.h @@ -177,7 +103,7 @@ source_group("CUDA Source Files" FILES ${GpuCudaSources}) source_group("CUDA Model Files" FILES ${GpuCudaModels}) source_group("CUDA Estimator Files" FILES ${GpuCudaEstimators}) -cuda_add_library( Gpufit SHARED +add_library( Gpufit SHARED ${GpuHeaders} ${GpuSources} ${GpuCudaHeaders} @@ -192,40 +118,19 @@ set_target_properties( Gpufit CXX_VISIBILITY_PRESET hidden ) -# USE_CUBLAS -if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND CUDA_VERSION VERSION_GREATER "6.5") +# USE_CUBLAS +if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER "6.5") set( USE_CUBLAS ${DEFAULT_USE_CUBLAS} CACHE BOOL "ON | OFF") if( USE_CUBLAS ) - if ( WIN32 ) - set( CUBLAS_DLL - "${CUDA_TOOLKIT_ROOT_DIR}/bin/cublas64_${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}.dll" ) - add_custom_command( TARGET Gpufit POST_BUILD - COMMAND ${CMAKE_COMMAND} -E - copy_if_different ${CUBLAS_DLL} $ ) - target_link_libraries( Gpufit ${CUDA_CUBLAS_LIBRARIES} ) - else() + find_package(CUDAToolkit REQUIRED) set( STATIC_CUBLAS ON CACHE BOOL "ON | OFF") if ( STATIC_CUBLAS ) - find_cuda_helper_libs(cublas_static) - find_cuda_helper_libs(cublasLt_static) - find_cuda_helper_libs(culibos) - - set( CUDA_CUBLAS_LIBRARIES - ${CUDA_cublas_static_LIBRARY} - ${CUDA_cublasLt_static_LIBRARY} - ${CUDA_cudart_static_LIBRARY} - ${CUDA_culibos_LIBRARY} - dl - pthread - rt ) - target_link_libraries( Gpufit ${CUDA_CUBLAS_LIBRARIES} ) + target_link_libraries( Gpufit CUDA::cublas_static CUDA::cublasLt_static) else () - # Dynamic Link can be done with a single function call - CUDA_ADD_CUBLAS_TO_TARGET( Gpufit ) + target_link_libraries( Gpufit CUDA::cublas CUDA::cublasLt) endif () + add_definitions( -DUSE_CUBLAS ) endif() - add_definitions( -DUSE_CUBLAS ) - endif() elseif( CMAKE_SIZEOF_VOID_P EQUAL 4 ) message( STATUS "CUBLAS: 32-bit architecture detected; USE_CUBLAS flag ignored." ) elseif( CUDA_VERSION VERSION_LESS "7.0" ) diff --git a/Gpufit/examples/CMakeLists.txt b/Gpufit/examples/CMakeLists.txt index d92178c1..c59874c2 100644 --- a/Gpufit/examples/CMakeLists.txt +++ b/Gpufit/examples/CMakeLists.txt @@ -8,7 +8,7 @@ function( add_example module name ) endfunction() function( add_cuda_example module name ) - cuda_add_executable( ${name} ${name}.cu ) + add_executable( ${name} ${name}.cu ) target_link_libraries( ${name} ${module} ) set_property( TARGET ${name} PROPERTY RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" ) From de2a0d76b5aa0a547d00cadc2eca8784b60b2807 Mon Sep 17 00:00:00 2001 From: Sam Scholten Date: Thu, 6 Oct 2022 22:19:50 +1100 Subject: [PATCH 08/11] Include for >=gcc-11 Resolves #106 --- Gpufit/info.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Gpufit/info.cpp b/Gpufit/info.cpp index 4e5378a8..26dca43f 100644 --- a/Gpufit/info.cpp +++ b/Gpufit/info.cpp @@ -1,5 +1,6 @@ #include "info.h" #include +#include Info::Info() : n_parameters_(0), From 909a932e52ace0ba2f526b19a734302cc475d922 Mon Sep 17 00:00:00 2001 From: S Barnes Date: Thu, 5 Sep 2019 15:14:39 -0700 Subject: [PATCH 09/11] created .deb file for linux install --- package/control | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 package/control diff --git a/package/control b/package/control new file mode 100644 index 00000000..cc549101 --- /dev/null +++ b/package/control @@ -0,0 +1,10 @@ +Package: gpufit +Version: version_string +Section: base +Priority: optional +Architecture: amd64 +Depends: +Maintainer: Samuel Barnes +Description: GPU-accelerated Levenberg-Marquardt curve fitting toolkit, implemented in CUDA + Requires CUDA video card and driver + Python, Java, and Matlab bindings From 7525638d04b7dd4c085686a28972f3c341ef0e3f Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Tue, 11 Oct 2022 13:21:58 -0700 Subject: [PATCH 10/11] add cuda include dir to c++ compiles --- Gpufit/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gpufit/CMakeLists.txt b/Gpufit/CMakeLists.txt index c29f8f0c..d24c7367 100644 --- a/Gpufit/CMakeLists.txt +++ b/Gpufit/CMakeLists.txt @@ -118,6 +118,8 @@ set_target_properties( Gpufit CXX_VISIBILITY_PRESET hidden ) +target_include_directories( Gpufit SYSTEM PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) + # USE_CUBLAS if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER "6.5") set( USE_CUBLAS ${DEFAULT_USE_CUBLAS} CACHE BOOL "ON | OFF") From be45592d24a24aeb000ceb2eb2e029cb4cc76e19 Mon Sep 17 00:00:00 2001 From: Sam Barnes Date: Tue, 11 Oct 2022 14:34:22 -0700 Subject: [PATCH 11/11] attempt to fix static linking with msvc --- CMakeLists.txt | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba4c83d7..77464fe0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ cmake_minimum_required( VERSION 3.11 ) set_property( GLOBAL PROPERTY USE_FOLDERS ON ) +cmake_policy(SET CMP0091 NEW) if( NOT PROJECT_NAME ) project( Gpufit VERSION 1.2.0 LANGUAGES CUDA CXX) @@ -15,17 +16,17 @@ endif() if( NOT CMAKE_CXX_STANDARD ) set( CMAKE_CXX_STANDARD 14 ) endif() - -if( MSVC ) # link runtime statically with MSVC - foreach( type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} ) - string( TOUPPER ${type} TYPE ) - foreach( flags CMAKE_C_FLAGS_${TYPE} CMAKE_CXX_FLAGS_${TYPE} ) - get_property( help CACHE ${flags} PROPERTY HELPSTRING ) - string( REPLACE "/MD" "/MT" ${flags} "${${flags}}" ) - set( ${flags} "${${flags}}" CACHE STRING "${help}" FORCE ) - endforeach() - endforeach() -endif() + +#if( MSVC ) # link runtime statically with MSVC +# foreach( type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} ) +# string( TOUPPER ${type} TYPE ) +# foreach( flags CMAKE_C_FLAGS_${TYPE} CMAKE_CXX_FLAGS_${TYPE} ) +# get_property( help CACHE ${flags} PROPERTY HELPSTRING ) +# string( REPLACE "/MD" "/MT" ${flags} "${${flags}}" ) +# set( ${flags} "${${flags}}" CACHE STRING "${help}" FORCE ) +# endforeach() +# endforeach() +#endif() function( add_launcher target executable arguments working_directory ) if( MSVC12 OR MSVC14 ) @@ -144,6 +145,14 @@ add_subdirectory( Gpufit ) add_subdirectory( examples/c++/gpu_vs_cpu_profiling ) + +# link runtime statically with MSVC +set_property(TARGET Gpufit PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +set_property(TARGET Cpufit PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + + # Launcher # # Uses the following variables: