From 0471f063e29ce725f3295a58d323aafbd0dd91e3 Mon Sep 17 00:00:00 2001 From: "Miller, Samuel" Date: Tue, 23 Jun 2020 18:45:43 +0000 Subject: [PATCH] Adding some debug/cmake settings for vscode --- .devcontainer/devcontainer.json | 4 +-- .vscode/launch.json | 14 +++----- .vscode/tasks.json | 39 +++++++++++++++++++++ cmake-variants.yaml | 61 +++++++++++++++++++++++++++++++++ cmake/SetFortranFlags.cmake | 18 ++++++++-- 5 files changed, 123 insertions(+), 13 deletions(-) create mode 100644 .vscode/tasks.json create mode 100644 cmake-variants.yaml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0c3a86b..9c4feed 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,17 +2,17 @@ // https://github.com/microsoft/vscode-dev-containers/tree/master/containers/alpine-3.10-git { "name": "Fortran+MPI", - "image": "smillerc/ifort-mpi-dev", + "image": "smillerc/gfortran-dev:latest", "settings": { "terminal.integrated.shell.linux": "/bin/bash", "fortran-ls.executablePath": "/miniconda/bin/fortls" }, + "postAttachCommand": "pip install fortran-language-server jsonrpc2 --user", "extensions": [ "ms-vscode.cmake-tools", "twxs.cmake", "krvajalm.fortran", "hansec.fortran-ls", "eamodio.gitlens", - "gimly81.fortran" ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index 34d610b..a03a63a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,23 +1,19 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { - "name": "Fortran Launch (GDB)", + "name": "(gdb) Launcher", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/bin/cato.x", "args": [ "input.ini" ], - "miDebuggerPath": "/usr/bin/gdb", "stopAtEntry": false, - "cwd": "${workspaceFolder}/tests/integrated/double_shear", + "cwd": "${workspaceFolder}/tests/integrated/sod_1d", "environment": [], - "externalConsole": true, - // "preLaunchTask": "/usr/local/bin/gfortran-9" - }, + "externalConsole": false, + "MIMode": "gdb", + } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..82acc59 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,39 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "Config Debug GCC", + "command": "cmake", + "args": [ + "..", + "-DCMAKE_BUILD_TYPE='Debug'", + "-DENABLE_TESTING=NO", + "-DUSE_OPENMP=YES", + "-DENABLE_PROFILING=NO", + ], + "options": { + "cwd": "${workspaceFolder}/build", + }, + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "type": "shell", + "label": "Build", + "command": "make", + "args": [ + "-j" + ], + "options": { + "cwd": "${workspaceFolder}/build", + }, + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/cmake-variants.yaml b/cmake-variants.yaml new file mode 100644 index 0000000..44e5948 --- /dev/null +++ b/cmake-variants.yaml @@ -0,0 +1,61 @@ +buildType: + default: debug + choices: + debug: + short: Debug + long: Emit debug information + buildType: Debug + release: + short: Release + long: Optimize generated code + buildType: Release + asan: + short: Asan + long: Instrument with Address Sanitizer + buildType: Asan + tsan: + short: Tsan + long: Instrument with Thread Sanitizer + buildType: Tsan + +# EnableOpenMP: +# default: "yes" +# short: Enable OpenMP Testing +# choices: +# yes: +# short: OpenMP +# long: Enable OpenMP +# settings: +# USE_OPENMP: yes +# no: +# short: OpenMP +# long: Disable OpenMP +# settings: +# USE_OPENMP: no +EnableOpenMP: + default: yes + choices: + yes: + short: With_OpenMP + long: Enable PFUnit Unit testing + settings: + USE_OPENMP: YES + no: + short: Without_OpenMP + long: Disable PFUnit Unit testing + settings: + USE_OPENMP: NO + +EnableTesting: + default: no + choices: + yes: + short: With_PFUnit + long: Enable PFUnit Unit testing + settings: + DENABLE_TESTING: YES + no: + short: Without_PFUnit + long: Disable PFUnit Unit testing + settings: + DENABLE_TESTING: NO diff --git a/cmake/SetFortranFlags.cmake b/cmake/SetFortranFlags.cmake index b962125..0114f61 100755 --- a/cmake/SetFortranFlags.cmake +++ b/cmake/SetFortranFlags.cmake @@ -55,8 +55,19 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-loops -finline-functions ${GNUNATIVE}") - if(ENABLE_PROFILING) - # set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fsanitize=leak -fsanitize=address") + if(NOT USE_ASAN) + set(USE_ASAN Off) + endif() + + if(NOT USE_TSAN) + set(USE_TSAN Off) + endif() + + if(USE_ASAN) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fsanitize=leak -fsanitize=address") + endif() + + if(USE_TSAN) set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fsanitize=thread") endif() @@ -65,6 +76,9 @@ endif() # ifort if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) + if (USE_ASAN or USE_TSAN) + message(FATAL_ERROR "Cannot enable USE_ASAN or USE_TSAN with the Intel Fortran Compiler, this is a GCC/Clang feature") + endif() # if(SERIAL_BUILD) set(IFORT_COARRAY "-coarray=single") elseif(SHARED_MEMORY) set(IFORT_COARRAY # "-coarray=shared") elseif(DISTRIBUTED_MEMORY) set(IFORT_COARRAY "-coarray=distributed") endif()