From 7f71189619700e05b637a18f36f4d78b96b7acee Mon Sep 17 00:00:00 2001 From: Izaak Beekman Date: Thu, 12 Dec 2024 15:57:20 -0500 Subject: [PATCH 1/3] Fix myhi.f --- tests/fortran/myhi.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fortran/myhi.f b/tests/fortran/myhi.f index 883e5c4..e200628 100644 --- a/tests/fortran/myhi.f +++ b/tests/fortran/myhi.f @@ -6,7 +6,7 @@ subroutine HELLOWORLD(iVal) integer iVal cc Do something here... - print *, "Iteration = ", iVal + print *, "Iteration = ", iVal cc HelloWorld = iVal end From 319c42f7c1b3196db77434af9656460dfead64d7 Mon Sep 17 00:00:00 2001 From: Izaak Beekman Date: Thu, 12 Dec 2024 15:59:19 -0500 Subject: [PATCH 2/3] Add script to wrap the running of the plugin --- src/fparse-llvm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 src/fparse-llvm diff --git a/src/fparse-llvm b/src/fparse-llvm new file mode 100755 index 0000000..29e298c --- /dev/null +++ b/src/fparse-llvm @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Copyright (C) 2024, ParaTools, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +set -o errexit +set -o nounset +set -o pipefail +#set -o verbose +#set -o xtrace + +# This script invokes an LLVM flang frontend plugin to parse and instrument Fortran code +flang-new -fc1 -load ./libsalt-flang-plugin.so -plugin salt-instrument "${@}" From 4beb1cb902ffeebc054ad4a072f8f230f540e800 Mon Sep 17 00:00:00 2001 From: Izaak Beekman Date: Thu, 12 Dec 2024 16:28:15 -0500 Subject: [PATCH 3/3] Run fparse-llvm isntrumentor on Fortran test files --- CMakeLists.txt | 27 +++++++++++++++++++++++++++ src/{fparse-llvm => fparse-llvm.in} | 0 2 files changed, 27 insertions(+) rename src/{fparse-llvm => fparse-llvm.in} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a258ac..da67055 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,6 +297,10 @@ if(MLIR_FOUND AND Flang_FOUND) install(TARGETS salt-flang-plugin DESTINATION lib) + configure_file(${CMAKE_SOURCE_DIR}/src/fparse-llvm.in ${CMAKE_BINARY_DIR}/fparse-llvm @ONLY) + install(PROGRAMS ${CMAKE_BINARY_DIR}/fparse-llvm + TYPE BIN) + else() message(STATUS "Flang not found -- skipping Flang frontend plugin") endif() @@ -593,3 +597,26 @@ endfunction() foreach(test_source IN LISTS TESTS_LIST) compile_instrumented(${test_source}) endforeach() + +# Add some Fortran tests for SALT-FM +set(FORTRAN_TESTS_SOURCES_LIST + myhi.f + cubes.f + emptyprog.f90 + funcsub.f90 + hello.f90 + loop_test.f90 + trivial.f90 +) + +foreach(test_source IN LISTS FORTRAN_TESTS_SOURCES_LIST) + add_test(NAME instrument_${test_source} + COMMAND ./fparse-llvm ${CMAKE_SOURCE_DIR}/tests/fortran/${test_source} + ) + set_tests_properties(instrument_${test_source} + PROPERTIES + REQUIRED_FILES "${CMAKE_BINARY_DIR}/fparse-llvm" + ENVIRONMENT "SALT_FORTRAN_CONFIG_FILE=${CMAKE_SOURCE_DIR}/config_files/tau_fortran_config.yaml" + PASS_REGULAR_EXPRESSION "SALT Instrumentor Plugin finished" + ) +endforeach() diff --git a/src/fparse-llvm b/src/fparse-llvm.in similarity index 100% rename from src/fparse-llvm rename to src/fparse-llvm.in