From d0583a4edb573ff785be8764bdabc774b291f6da Mon Sep 17 00:00:00 2001 From: Lukas Rothenberger Date: Wed, 18 Oct 2023 11:28:45 +0200 Subject: [PATCH] fix[todo]: moved FileMapping.txt to .discopop folder --- DiscoPoP/DiscoPoP.cpp | 6 ------ discopop_explorer/__main__.py | 2 +- .../discopop_optimizer/__main__.py | 2 +- docs/How_to_contribute.md | 5 ++--- example/execute_cmake_example.sh | 8 ++------ scripts/CC_wrapper.sh | 2 +- scripts/CXX_wrapper.sh | 2 +- scripts/MPI_CC_wrapper.sh | 18 +++++++++--------- scripts/MPI_CXX_wrapper.sh | 18 +++++++++--------- scripts/runDiscoPoP | 2 +- share/lib/DPUtils.cpp | 8 ++++---- 11 files changed, 31 insertions(+), 42 deletions(-) diff --git a/DiscoPoP/DiscoPoP.cpp b/DiscoPoP/DiscoPoP.cpp index 41d585d78..f3e63a8b0 100644 --- a/DiscoPoP/DiscoPoP.cpp +++ b/DiscoPoP/DiscoPoP.cpp @@ -123,12 +123,6 @@ bool DiscoPoP::doInitialization(Module &M) { mkdir(".discopop/profiler", 0777); } - // prepare common_data directory if not present - struct stat st3 = {0}; - if (stat(".discopop/common_data", &st3) == -1){ - mkdir(".discopop/common_data", 0777); - } - // CUGeneration { diff --git a/discopop_explorer/__main__.py b/discopop_explorer/__main__.py index c7a476aae..da61e6021 100644 --- a/discopop_explorer/__main__.py +++ b/discopop_explorer/__main__.py @@ -42,7 +42,7 @@ def parse_args() -> ExplorerArguments: help="Reduction variables file" ) parser.add_argument( - "--fmap", type=str, default="common_data/FileMapping.txt", + "--fmap", type=str, default="FileMapping.txt", help="File mapping") parser.add_argument( "--plugins", type=str, nargs="*", default=[], diff --git a/discopop_library/discopop_optimizer/__main__.py b/discopop_library/discopop_optimizer/__main__.py index 0a736e2db..08739ddc6 100644 --- a/discopop_library/discopop_optimizer/__main__.py +++ b/discopop_library/discopop_optimizer/__main__.py @@ -17,7 +17,7 @@ OPTIONAL ARGUMENTS: --project= Path to the directory that contains your makefile [default: .] - --file-mapping= Path to the FileMapping.txt. [default: common_data/FileMapping.txt] + --file-mapping= Path to the FileMapping.txt. [default: FileMapping.txt] --detection-result-dump= Path to the dumped detection result JSON. [default: explorer/detection_result_dump.json] --execute-created-models Compiles, executes and measures models already stored in the project folder. Does not start the optimization pipeline. diff --git a/docs/How_to_contribute.md b/docs/How_to_contribute.md index 80fdc27e4..93265905e 100644 --- a/docs/How_to_contribute.md +++ b/docs/How_to_contribute.md @@ -71,8 +71,7 @@ All tools developed as part of the DiscoPop Project make use of the following fo ``` - project root/ - .discopop/ - - common_data/ - - FileMapping.txt + - FileMapping.txt - / - tool_1 output files - private/ @@ -82,7 +81,7 @@ All tools developed as part of the DiscoPop Project make use of the following fo - ... ``` , where no data should be stored / created outside the `.discopop` folder in order to keep the users build directory as clean as possible. -Files which are read by different tools, e.g. the `FileMapping.txt`, shall be stored in the `.discopop/common_data` folder. +Files which are read by different tools, e.g. the `FileMapping.txt`, shall be stored in the `.discopop` folder. Each tool may create a folder. In case data from these files is required by another tool, think about how to encode the information in a easy-to-use and structured format, preferrably JSON. If possible, please do not rely on exporting to simple `.txt` files as parsing adds a potential point of failure. Output data for use by other tools should be stored in the folder of the creating tool. Intermediate files may be stored in a folder named `private` and shall not be used by other tools. Analysis tools, like pattern detection scripts etc. shall be structured in such a way, that a execution from within the `.discopop` folder is intended. diff --git a/example/execute_cmake_example.sh b/example/execute_cmake_example.sh index 453139efc..85c012779 100755 --- a/example/execute_cmake_example.sh +++ b/example/execute_cmake_example.sh @@ -16,18 +16,14 @@ DISCOPOP_BUILD_DIR=$(pwd)/../build rm -rf build mkdir build -# generate FileMapping.txt -${DISCOPOP_BUILD_DIR}/scripts/dp-fmap - # Use DiscoPoP's compiler wrappers to build the cmake example # CMAKE_wrapper.sh acts as a substitute for the `cmake` command cd build ${DISCOPOP_BUILD_DIR}/scripts/CMAKE_wrapper.sh .. -# Set the DP_FM_PATH environment variable -DP_FM_PATH=${EXAMPLE_DIR}/../FileMapping.txt make +make # execute the example ./cmake_example -# Now, profiling results (e.g. cmake_example_dep.txt (dynamically identified data dependencies)) are available +# Now, profiling results (e.g. dynamically identified data dependencies) are available # The created output can be used for pattern detection using the discopop_explorer. # Please refer to the Wiki for detailed information and instructions. diff --git a/scripts/CC_wrapper.sh b/scripts/CC_wrapper.sh index 511840b46..a5f344820 100755 --- a/scripts/CC_wrapper.sh +++ b/scripts/CC_wrapper.sh @@ -39,7 +39,7 @@ echo "DP_FM_PATH: ${DP_FM_PATH}" # exit 1 #fi -echo "${LLVM_CLANG} -g -c -O0 -S -emit-llvm -fno-discard-value-names ${@} -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -mllvm --fm-path -mllvm ${DP_FM_PATH} " +echo "${LLVM_CLANG} -g -c -O0 -S -emit-llvm -fno-discard-value-names ${@} -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP" #clang-11 -g -c -O0 -S -emit-llvm -fno-discard-value-names "$@" -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -mllvm --fm-path -mllvm ${DP_FM_PATH} ${LLVM_CLANG} "$@" -g -O0 -fno-discard-value-names -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -fPIC -Xlinker -L${DP_BUILD}/rtlib -Xlinker -lDiscoPoP_RT -Xlinker -lpthread -Xlinker -v -Xlinker -lstdc++ diff --git a/scripts/CXX_wrapper.sh b/scripts/CXX_wrapper.sh index 70ac6eac2..a31cbdbb5 100755 --- a/scripts/CXX_wrapper.sh +++ b/scripts/CXX_wrapper.sh @@ -39,7 +39,7 @@ echo "DP_FM_PATH: ${DP_FM_PATH}" # exit 1 #fi -echo "${LLVM_CLANGPP} -g -c -O0 -S -emit-llvm -fno-discard-value-names ${@} -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -mllvm --fm-path -mllvm ${DP_FM_PATH} " +echo "${LLVM_CLANGPP} -g -c -O0 -S -emit-llvm -fno-discard-value-names ${@} -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP" #clang++-11 -g -c -O0 -S -emit-llvm -fno-discard-value-names "$@" -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -mllvm --fm-path -mllvm ${DP_FM_PATH} ${LLVM_CLANGPP} "$@" -g -O0 -fno-discard-value-names -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -fPIC -Xlinker -L${DP_BUILD}/rtlib -Xlinker -lDiscoPoP_RT -Xlinker -lpthread -Xlinker -v # WARNING: OUTPUT IS A .ll FILE, ENDING IS .o diff --git a/scripts/MPI_CC_wrapper.sh b/scripts/MPI_CC_wrapper.sh index f72a14296..1de5a7cb8 100755 --- a/scripts/MPI_CC_wrapper.sh +++ b/scripts/MPI_CC_wrapper.sh @@ -39,15 +39,15 @@ echo "WRAPPED MPI CC COMPILE..." echo "ARGS: ${@}" echo "DP_FM_PATH: ${DP_FM_PATH}" -# check if environment is prepared -if [ -z ${DP_FM_PATH} ]; then - echo "ERROR: DP_FM_PATH unspecified!" - echo " Generate a FileMapping.txt file and create an environment Variable which points to this file." - echo " Please refer to https://discopop-project.github.io/discopop/Profiling/File_Mapping/ for further information." - exit 1 -fi - -echo "${LLVM_CLANG} ${MPI_INCLUDES} -g -c -S -emit-llvm -fno-discard-value-names ${@} -O0 -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -mllvm --fm-path -mllvm ${DP_FM_PATH}" +## check if environment is prepared +#if [ -z ${DP_FM_PATH} ]; then +# echo "ERROR: DP_FM_PATH unspecified!" +# echo " Generate a FileMapping.txt file and create an environment Variable which points to this file." +# echo " Please refer to https://discopop-project.github.io/discopop/Profiling/File_Mapping/ for further information." +# exit 1 +#fi + +echo "${LLVM_CLANG} ${MPI_INCLUDES} -g -c -S -emit-llvm -fno-discard-value-names ${@} -O0 -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP" #clang-11 -g -c -O0 -S -emit-llvm -fno-discard-value-names "$@" -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -mllvm --fm-path -mllvm ${DP_FM_PATH} ${LLVM_CLANG} "${@}" -g -c -O0 -fno-discard-value-names -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -fPIC ${MPI_INCLUDES} -Xlinker -lstdc++ diff --git a/scripts/MPI_CXX_wrapper.sh b/scripts/MPI_CXX_wrapper.sh index b053454bc..c5ef65899 100755 --- a/scripts/MPI_CXX_wrapper.sh +++ b/scripts/MPI_CXX_wrapper.sh @@ -39,15 +39,15 @@ echo "WRAPPED MPI CXX COMPILE..." echo "ARGS: ${@}" echo "DP_FM_PATH: ${DP_FM_PATH}" -# check if environment is prepared -if [ -z ${DP_FM_PATH} ]; then - echo "ERROR: DP_FM_PATH unspecified!" - echo " Generate a FileMapping.txt file and create an environment Variable which points to this file." - echo " Please refer to https://discopop-project.github.io/discopop/Profiling/File_Mapping/ for further information." - exit 1 -fi - -echo "${LLVM_CLANGPP} ${MPI_INCLUDES} -g -c -O0 -S -emit-llvm -fno-discard-value-names ${@} -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -mllvm --fm-path -mllvm ${DP_FM_PATH}" +## check if environment is prepared +#if [ -z ${DP_FM_PATH} ]; then +# echo "ERROR: DP_FM_PATH unspecified!" +# echo " Generate a FileMapping.txt file and create an environment Variable which points to this file." +# echo " Please refer to https://discopop-project.github.io/discopop/Profiling/File_Mapping/ for further information." +# exit 1 +#fi + +echo "${LLVM_CLANGPP} ${MPI_INCLUDES} -g -c -O0 -S -emit-llvm -fno-discard-value-names ${@} -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP" #clang++-11 -g -c -O0 -S -emit-llvm -fno-discard-value-names "$@" -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -mllvm --fm-path -mllvm ${DP_FM_PATH} ${LLVM_CLANGPP} "$@" -g -c -O0 -fno-discard-value-names -Xclang -load -Xclang ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP -fPIC ${MPI_INCLUDES} diff --git a/scripts/runDiscoPoP b/scripts/runDiscoPoP index f092ea6ea..b147b5a4e 100755 --- a/scripts/runDiscoPoP +++ b/scripts/runDiscoPoP @@ -372,7 +372,7 @@ fi # Run DiscoPoP Pass log -i "Running DiscoPoP Pass to analyze and instrument your application..." -$LLVM_OPT -S -load ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP ${EXECUTABLE_NAME}.ll -o ${EXECUTABLE_NAME}_dp.ll -fm-path FileMapping.txt ${DP_PASS_FLAGS} +$LLVM_OPT -S -load ${DP_BUILD}/libi/LLVMDiscoPoP.so -DiscoPoP ${EXECUTABLE_NAME}.ll -o ${EXECUTABLE_NAME}_dp.ll ${DP_PASS_FLAGS} log -i "Creating Executable..." $LLVM_LLC -filetype=obj ${EXECUTABLE_NAME}_dp.ll -o ${EXECUTABLE_NAME}_dp.o diff --git a/share/lib/DPUtils.cpp b/share/lib/DPUtils.cpp index 65ebcc4c7..d52b2924b 100644 --- a/share/lib/DPUtils.cpp +++ b/share/lib/DPUtils.cpp @@ -16,7 +16,7 @@ using namespace std; //cl::opt FileMappingPath("fm-path", cl::init(""), // cl::desc("Specify file mapping location"), cl::Hidden); -string FileMappingPath = ".discopop/common_data/FileMapping.txt"; +string FileMappingPath = ".discopop/FileMapping.txt"; cl::opt DP_MEMORY_PROFILING_SKIP_FUNCTION_ARGUMENTS("memory-profiling-skip-function-arguments", cl::init(false), @@ -28,7 +28,7 @@ namespace dputil { int tempfid = 1; fstream fileMappingFile; - fileMappingFile.open(".discopop/common_data/FileMapping.txt", ios::in); + fileMappingFile.open(".discopop/FileMapping.txt", ios::in); if (fileMappingFile) { string tp; @@ -43,7 +43,7 @@ namespace dputil { } fileMappingFile.close(); - fileMappingFile.open(".discopop/common_data/FileMapping.txt", std::ios_base::app); + fileMappingFile.open(".discopop/FileMapping.txt", std::ios_base::app); fileMappingFile << tempfid << "\t" << fullPathName << "\n"; fileMappingFile.close(); errs() << "added fmap entry: " << tempfid << "\t" << fullPathName << "\n"; @@ -51,7 +51,7 @@ namespace dputil { } else { - fileMappingFile.open(".discopop/common_data/FileMapping.txt", std::ios_base::app); + fileMappingFile.open(".discopop/FileMapping.txt", std::ios_base::app); fileMappingFile << tempfid << "\t" << fullPathName << "\n"; fileMappingFile.close(); errs() << "added fmap entry: " << tempfid << "\t" << fullPathName << "\n";