Skip to content

Commit

Permalink
Merge pull request #6 from miguelcarcamov/development
Browse files Browse the repository at this point in the history
MERGE from Development
  • Loading branch information
miguelcarcamov authored Jul 9, 2022
2 parents e997794 + 55bbccb commit 98f29d3
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 205 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ repos:
- id: markdownlint-fix
entry: markdownlint -f README.md --disable MD013 MD036 MD033 MD046
# args: [--disable MD013 MD036]

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
# - id: cmake-lint
132 changes: 80 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(gpuvmem LANGUAGES C CXX CUDA)

include(CMakePrintHelpers) # In case we need to print any variable

# Set a default build type if not passed
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
message(
STATUS
"Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE
"${default_build_type}"
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif()

if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset the configurations to what we need"
FORCE)
set(CMAKE_CONFIGURATION_TYPES
"${CMAKE_CONFIGURATION_TYPES}"
CACHE STRING "Reset the configurations to what we need" FORCE)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
Expand All @@ -24,7 +29,8 @@ find_package(CFITSIO REQUIRED)
set(CASACORE_MAKE_REQUIRED_EXTERNALS_OPTIONAL TRUE)
find_package(Casacore REQUIRED COMPONENTS casa ms tables measures)
option(MEMORY_DEBUG "This sets the GDB debug for CUDA code")
option(USE_FAST_MATH "This option accelerate CUDA math functions decreasing precision")
option(USE_FAST_MATH
"This option accelerate CUDA math functions decreasing precision")
if(Boost_FOUND)
add_executable(gpuvmem ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cu)
# Search the compute capability of the first GPU and add CUDA specific FLAGS
Expand All @@ -35,28 +41,28 @@ if(Boost_FOUND)

if(PREFIX)
set(BINARY_DIR ${PREFIX})
set_target_properties(gpuvmem
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${BINARY_DIR}
)
set_target_properties(gpuvmem PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${BINARY_DIR})
else()
set(BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set_target_properties(gpuvmem
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${BINARY_DIR}
)
set_target_properties(gpuvmem PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${BINARY_DIR})
endif()
message(NOTICE "We are currently using the latest casacore stable version >=v3.2.1")
message(NOTICE "If one these versions are not installed in your computer, please make sure to install it")
message(NOTICE "For more information please read the README.md file")
target_include_directories(gpuvmem PUBLIC
${CASACORE_INCLUDE_DIRS}
${CFITSIO_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/classes
${Boost_INCLUDE_DIRS}
${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc
message(NOTICE
"We are currently using the latest casacore stable version >=v3.2.1")
message(
NOTICE
"If one these versions are not installed in your computer, please make sure to install it"
)
message(NOTICE "For more information please read the README.md file")
target_include_directories(
gpuvmem
PUBLIC ${CASACORE_INCLUDE_DIRS}
${CFITSIO_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/classes
${Boost_INCLUDE_DIRS}
${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc)

get_target_property(TEMP gpuvmem COMPILE_FLAGS)
if(TEMP STREQUAL "TEMP-NOTFOUND")
Expand All @@ -65,49 +71,71 @@ if(Boost_FOUND)
set(TEMP "${TEMP} ") # A space to cleanly separate from existing content
endif()

set_property(TARGET gpuvmem PROPERTY CUDA_ARCHITECTURES
${CUDA_NVCC_ARCH_FLAGS})

if(MEMORY_DEBUG)
message(NOTICE "MEMORY DEBUG IS ON")
set(COMPFLAGS "-g -G -D_FORCE_INLINES -w")
set(TEMP "${TEMP}${COMPFLAGS}" )
set_target_properties(gpuvmem PROPERTIES COMPILE_FLAGS ${TEMP} CUDA_SEPARABLE_COMPILATION ON CUDA_STANDARD 11)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -fopenmp ${CUDA_NVCC_ARCH_FLAGS}")
set(TEMP "${TEMP}${COMPFLAGS}")
set_target_properties(
gpuvmem
PROPERTIES COMPILE_FLAGS ${TEMP}
CUDA_SEPARABLE_COMPILATION ON
CUDA_STANDARD 11)
set(CMAKE_CUDA_FLAGS
"${CMAKE_CUDA_FLAGS} -Xcompiler -fopenmp ${CUDA_NVCC_ARCH_FLAGS}")
else()
message(NOTICE "MEMORY DEBUG IS OFF")
if(USE_FAST_MATH)
message(NOTICE "USING FAST_MATH")
set(COMPFLAGS "-D_FORCE_INLINES -w --use_fast_math -O3")
set(TEMP "${TEMP}${COMPFLAGS}" )
set_target_properties(gpuvmem PROPERTIES COMPILE_FLAGS ${TEMP} CUDA_SEPARABLE_COMPILATION ON CUDA_STANDARD 11)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xptxas -O3 -Xcompiler -fopenmp ${CUDA_NVCC_ARCH_FLAGS}")
set(TEMP "${TEMP}${COMPFLAGS}")
set_target_properties(
gpuvmem
PROPERTIES COMPILE_FLAGS ${TEMP}
CUDA_SEPARABLE_COMPILATION ON
CUDA_STANDARD 11)
set(CMAKE_CUDA_FLAGS
"${CMAKE_CUDA_FLAGS} -Xptxas -O3 -Xcompiler -fopenmp ${CUDA_NVCC_ARCH_FLAGS}"
)
else()
set(COMPFLAGS "-D_FORCE_INLINES -w -O3")
set(TEMP "${TEMP}${COMPFLAGS}" )
set_target_properties(gpuvmem PROPERTIES COMPILE_FLAGS ${TEMP} CUDA_SEPARABLE_COMPILATION ON CUDA_STANDARD 11)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xptxas -O3 -Xcompiler -fopenmp ${CUDA_NVCC_ARCH_FLAGS}")
set(TEMP "${TEMP}${COMPFLAGS}")
set_target_properties(
gpuvmem
PROPERTIES COMPILE_FLAGS ${TEMP}
CUDA_SEPARABLE_COMPILATION ON
CUDA_STANDARD 11)
set(CMAKE_CUDA_FLAGS
"${CMAKE_CUDA_FLAGS} -Xptxas -O3 -Xcompiler -fopenmp")
endif()
endif()

set(ALL_CUDA_LIBRARIES
${CUDA_cuda_LIBRARY}
${CUDA_cudart_LIBRARY}
${CUDA_cufft_LIBRARY}
)
set(ALL_LIBRARIES
${CASACORE_LIBRARIES}
${CFITSIO_LIBRARY}
${Boost_LIBRARIES}
)
target_link_libraries(gpuvmem m stdc++ gomp ${ALL_CUDA_LIBRARIES} ${ALL_LIBRARIES})
set(ALL_CUDA_LIBRARIES ${CUDA_cuda_LIBRARY} ${CUDA_cudart_LIBRARY}
${CUDA_cufft_LIBRARY})
set(ALL_LIBRARIES ${CASACORE_LIBRARIES} ${CFITSIO_LIBRARY} ${Boost_LIBRARIES})

target_link_libraries(gpuvmem m stdc++ gomp ${ALL_CUDA_LIBRARIES}
${ALL_LIBRARIES})
# Adding install target
install(TARGETS gpuvmem DESTINATION bin)
# Tests - Tests all the testing datasets
enable_testing()
set(TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)
add_test(antennae bash ${TEST_DIRECTORY}/antennae/test.sh ${BINARY_DIR}/gpuvmem ${TEST_DIRECTORY}/antennae)
add_test(co65 bash ${TEST_DIRECTORY}/co65/test.sh ${BINARY_DIR}/gpuvmem ${TEST_DIRECTORY}/co65)
add_test(freq78 bash ${TEST_DIRECTORY}/FREQ78/test.sh ${BINARY_DIR}/gpuvmem ${TEST_DIRECTORY}/FREQ78)
add_test(m87 bash ${TEST_DIRECTORY}/M87/test.sh ${BINARY_DIR}/gpuvmem ${TEST_DIRECTORY}/M87)
add_test(selfcalband9 bash ${TEST_DIRECTORY}/selfcalband9/test.sh ${BINARY_DIR}/gpuvmem ${TEST_DIRECTORY}/selfcalband9)
add_test(antennae bash ${TEST_DIRECTORY}/antennae/test.sh
${BINARY_DIR}/gpuvmem ${TEST_DIRECTORY}/antennae)
add_test(co65 bash ${TEST_DIRECTORY}/co65/test.sh ${BINARY_DIR}/gpuvmem
${TEST_DIRECTORY}/co65)
add_test(freq78 bash ${TEST_DIRECTORY}/FREQ78/test.sh ${BINARY_DIR}/gpuvmem
${TEST_DIRECTORY}/FREQ78)
add_test(m87 bash ${TEST_DIRECTORY}/M87/test.sh ${BINARY_DIR}/gpuvmem
${TEST_DIRECTORY}/M87)
add_test(selfcalband9 bash ${TEST_DIRECTORY}/selfcalband9/test.sh
${BINARY_DIR}/gpuvmem ${TEST_DIRECTORY}/selfcalband9)
else()
message(NOTICE Boost is not installed in your system. Please make sure Boost is installed before compiling.)
message(
NOTICE
"Boost is not installed in your system. Please make sure Boost is installed before compiling."
)
endif()
57 changes: 27 additions & 30 deletions cmake/FindCFITSIO.cmake
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
# - Try to find CFITSIO.
# Variables used by this module:
# CFITSIO_ROOT_DIR - CFITSIO root directory
# Variables defined by this module:
# CFITSIO_FOUND - system has CFITSIO
# CFITSIO_INCLUDE_DIR - the CFITSIO include directory (cached)
# CFITSIO_INCLUDE_DIRS - the CFITSIO include directories
# (identical to CFITSIO_INCLUDE_DIR)
# CFITSIO_LIBRARY - the CFITSIO library (cached)
# CFITSIO_LIBRARIES - the CFITSIO libraries
# (identical to CFITSIO_LIBRARY)
# * Try to find CFITSIO. Variables used by this module: CFITSIO_ROOT_DIR -
# CFITSIO root directory Variables defined by this module: CFITSIO_FOUND -
# system has CFITSIO CFITSIO_INCLUDE_DIR - the CFITSIO include directory
# (cached) CFITSIO_INCLUDE_DIRS - the CFITSIO include directories (identical
# to CFITSIO_INCLUDE_DIR) CFITSIO_LIBRARY - the CFITSIO library (cached)
# CFITSIO_LIBRARIES - the CFITSIO libraries (identical to CFITSIO_LIBRARY)

# Copyright (C) 2009
# ASTRON (Netherlands Institute for Radio Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
# Copyright (C) 2009 ASTRON (Netherlands Institute for Radio Astronomy) P.O.Box
# 2, 7990 AA Dwingeloo, The Netherlands
#
# This file is part of the LOFAR software suite.
# The LOFAR software suite is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This file is part of the LOFAR software suite. The LOFAR software suite is
# free software: you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# The LOFAR software suite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License along with
# the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
#
# $Id: FindCFITSIO.cmake 22498 2012-10-23 10:51:12Z loose $

if(NOT CFITSIO_FOUND)

find_path(CFITSIO_INCLUDE_DIR fitsio.h
HINTS ${CFITSIO_ROOT_DIR} PATH_SUFFIXES include include/cfitsio include/libcfitsio0)
find_library(CFITSIO_LIBRARY cfitsio
HINTS ${CFITSIO_ROOT_DIR} PATH_SUFFIXES lib)
find_path(
CFITSIO_INCLUDE_DIR fitsio.h
HINTS ${CFITSIO_ROOT_DIR}
PATH_SUFFIXES include include/cfitsio include/libcfitsio0)
find_library(
CFITSIO_LIBRARY cfitsio
HINTS ${CFITSIO_ROOT_DIR}
PATH_SUFFIXES lib)
find_library(M_LIBRARY m)
mark_as_advanced(CFITSIO_INCLUDE_DIR CFITSIO_LIBRARY M_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CFITSIO DEFAULT_MSG
CFITSIO_LIBRARY M_LIBRARY CFITSIO_INCLUDE_DIR)
find_package_handle_standard_args(CFITSIO DEFAULT_MSG CFITSIO_LIBRARY
M_LIBRARY CFITSIO_INCLUDE_DIR)

set(CFITSIO_INCLUDE_DIRS ${CFITSIO_INCLUDE_DIR})
set(CFITSIO_LIBRARIES ${CFITSIO_LIBRARY} ${M_LIBRARY})
Expand Down
Loading

0 comments on commit 98f29d3

Please sign in to comment.