Skip to content

Commit

Permalink
fix[todo]: moved FileMapping.txt to .discopop folder
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed Oct 18, 2023
1 parent 5e5b601 commit d0583a4
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 42 deletions.
6 changes: 0 additions & 6 deletions DiscoPoP/DiscoPoP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion discopop_explorer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
Expand Down
2 changes: 1 addition & 1 deletion discopop_library/discopop_optimizer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
OPTIONAL ARGUMENTS:
--project=<path> Path to the directory that contains your makefile [default: .]
--file-mapping=<path> Path to the FileMapping.txt. [default: common_data/FileMapping.txt]
--file-mapping=<path> Path to the FileMapping.txt. [default: FileMapping.txt]
--detection-result-dump=<path> 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.
Expand Down
5 changes: 2 additions & 3 deletions docs/How_to_contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>/
- tool_1 output files
- private/
Expand All @@ -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.
8 changes: 2 additions & 6 deletions example/execute_cmake_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion scripts/CC_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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++

Expand Down
2 changes: 1 addition & 1 deletion scripts/CXX_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 9 additions & 9 deletions scripts/MPI_CC_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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++

Expand Down
18 changes: 9 additions & 9 deletions scripts/MPI_CXX_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
2 changes: 1 addition & 1 deletion scripts/runDiscoPoP
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions share/lib/DPUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace std;

//cl::opt <string> 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 <bool> DP_MEMORY_PROFILING_SKIP_FUNCTION_ARGUMENTS("memory-profiling-skip-function-arguments", cl::init(false),
Expand All @@ -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;
Expand All @@ -43,15 +43,15 @@ 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";
return tempfid;
}
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";
Expand Down

0 comments on commit d0583a4

Please sign in to comment.