Skip to content

Commit

Permalink
Fixing github actions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nishant-sachdeva committed Oct 21, 2023
1 parent f19afc1 commit cb4c6a3
Show file tree
Hide file tree
Showing 140 changed files with 140 additions and 84,805 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "LLVM Manylinux",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "ghcr.io/iith-compilers/manylinux2014-llvm/manylinux2014-llvm:x86-llvm12"
"image": "ghcr.io/iith-compilers/manylinux2014-llvm/manylinux2014-llvm:x86-llvm14"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

build_sdist:
runs-on: ubuntu-latest
container: ghcr.io/iith-compilers/manylinux2014-llvm/manylinux2014-llvm:x86-llvm12
container: ghcr.io/iith-compilers/manylinux2014-llvm/manylinux2014-llvm:x86-llvm14
steps:
- uses: actions/checkout@v3

Expand Down
4 changes: 2 additions & 2 deletions Manylinux2014_Compliant_Source/pkg/IR2Vec/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ PyObject *IR2Vec_generateEmbeddings(PyObject *self, PyObject *args) {
// Thus , need to add one more .cpp in .so
const char *mode = "\0";

string vocab_path = seed_emb_path + "/seedEmbeddingVocab-300-llvm12.txt";
string vocab_path = seed_emb_path + "/seedEmbeddingVocab-llvm14.txt";
// const char*
// vocab_path=(seed_emb_path+"/seedEmbeddingVocab-300-llvm12.txt").c_str(); //
// vocab_path=(seed_emb_path+"/seedEmbeddingVocab-300-llvm14.txt").c_str(); //
// this should be exact path till .txt . *** NOT TAKING THIS AS USER
// DEFINED/PROVIDED ARGS ***
const char *level = "\0"; // remember that ir2vec accepts a char type for this
Expand Down
2 changes: 1 addition & 1 deletion Manylinux2014_Compliant_Source/pkg/Manifest.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ./seedEmbeddingVocab-300-llvm12.txt
include ./seedEmbeddingVocab-llvm14.txt
11 changes: 5 additions & 6 deletions Manylinux2014_Compliant_Source/pkg/regen-oracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ cd src/test-suite

rm -rf oracle

SEED_VERSION="llvm12"
SEED_VERSION="llvm14"
SRC_WD="PE-benchmarks"
DEST_FOLDER_LL="PE-benchmarks-llfiles-${SEED_VERSION}"
DEST_FOLDER_SYM="oracle/SYM_${SEED_VERSION}_f"
DEST_FOLDER_FA="oracle/FA_${SEED_VERSION}_f"
DEST_FOLDER_SYM_P="oracle/SYM_${SEED_VERSION}"
DEST_FOLDER_FA_P="oracle/FA_${SEED_VERSION}"
DEST_FOLDER_SYM_P="oracle/SYM_${SEED_VERSION}_p"
DEST_FOLDER_FA_P="oracle/FA_${SEED_VERSION}_p"

mkdir -p ${DEST_FOLDER_LL}

for d in ${SRC_WD}/*.c ${SRC_WD}/*.cpp ${SRC_WD}/*.cc; do
echo "Compiling ${d} to IR"
name=$(basename ${d}) && oname=${name%.*} && clang -S -emit-llvm -Xclang -disable-O0-optnone ${d} -o ${DEST_FOLDER_LL}/${oname}.ll &
name=$(basename ${d}) && oname=${name%.*} && clang-14 -S -emit-llvm -Xclang -disable-O0-optnone ${d} -o ${DEST_FOLDER_LL}/${oname}.ll &
done
wait

Expand All @@ -28,8 +28,7 @@ mkdir -p ${DEST_FOLDER_SYM_P}
mkdir -p ${DEST_FOLDER_FA_P}

IR2VEC_PATH=../../build/bin/ir2vec

VOCAB_PATH="../../vocabulary/seedEmbeddingVocab-300-${SEED_VERSION}.txt"
VOCAB_PATH="../../vocabulary/seedEmbeddingVocab-${SEED_VERSION}.txt"

while IFS= read -r d; do
echo "Generating embeddings for ${d}"
Expand Down
12 changes: 10 additions & 2 deletions Manylinux2014_Compliant_Source/pkg/tests/test_ir2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ def test_fa_p():
full_path = str((TEST_SUITE_DIR / file).resolve()).strip()
output = IR2Vec.generateEmbeddings(full_path, "fa", "p")
p_vectors.append(output["Program_List"])

print(TEST_SUITE_DIR)
p_vectors_oracle = read_p_file(
TEST_SUITE_DIR / "oracle" / f"FA_{SEED_VERSION}" / "ir2vec.txt"
TEST_SUITE_DIR / "oracle" / f"FA_{SEED_VERSION}_p" / "ir2vec.txt"
)
for idx, v in enumerate(p_vectors):
assert v == pytest.approx(p_vectors_oracle[idx], abs=ABS_ACCURACY)
Expand All @@ -69,8 +71,10 @@ def test_sym_p():
full_path = str((TEST_SUITE_DIR / file).resolve()).strip()
output = IR2Vec.generateEmbeddings(full_path, "sym", "p")
p_vectors.append(output["Program_List"])

print(TEST_SUITE_DIR)
p_vectors_oracle = read_p_file(
TEST_SUITE_DIR / "oracle" / f"SYM_{SEED_VERSION}" / "ir2vec.txt"
TEST_SUITE_DIR / "oracle" / f"SYM_{SEED_VERSION}_p" / "ir2vec.txt"
)
for idx, v in enumerate(p_vectors):
assert v == pytest.approx(p_vectors_oracle[idx], abs=ABS_ACCURACY)
Expand All @@ -83,6 +87,8 @@ def test_fa_f():
output = IR2Vec.generateEmbeddings(str(full_path).strip(), "fa", "f")
for fun, vec in output["Function_Dict"].items():
f_vecs[full_path.name.strip()][fun.strip()] = vec

print(TEST_SUITE_DIR)
f_vecs_oracle = read_f_file(
TEST_SUITE_DIR / "oracle" / f"FA_{SEED_VERSION}_f" / "ir2vec.txt"
)
Expand All @@ -100,6 +106,8 @@ def test_sym_f():
output = IR2Vec.generateEmbeddings(str(full_path).strip(), "sym", "f")
for fun, vec in output["Function_Dict"].items():
f_vecs[full_path.name.strip()][fun.strip()] = vec

print(TEST_SUITE_DIR)
f_vecs_oracle = read_f_file(
TEST_SUITE_DIR / "oracle" / f"SYM_{SEED_VERSION}_f" / "ir2vec.txt"
)
Expand Down
4 changes: 2 additions & 2 deletions Manylinux2014_Compliant_Source/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AUTHORS : SHIKHAR JAIN (IITH COMPILERS) & ANILAVA KUNDU (IITH COMPILERS)
- In order to build from source you need to initiate a manylinux 2014 docker image and then use this source dir accordingly.
- While building source it is necessary to have a static library of LLVM that has all other static libs within it.
- These wheel files generated are specific for python abi versions as reflected by their names . But they will work on old/new *nix OSs.
- The package is specific for LLVM-12.0 and current IR2Vec main branch (1.1.0 verion)
- The package is specific for LLVM-14.0 and current IR2Vec main branch (1.1.0 verion)

- Inorder to use source on a MANYLINUX2014 Docker image and build it , there are several dependencies w.r.t static libs and header files .
- A static lib containing all the static libs of LLVM which can be found in llvm/buid_dir/lib.
Expand All @@ -29,7 +29,7 @@ AUTHORS : SHIKHAR JAIN (IITH COMPILERS) & ANILAVA KUNDU (IITH COMPILERS)
```
- Dir "llvm" : You can get this from llvm-project/llvm/include.
- Dir "llvm-c" : You can get this from llvm-project/llvm/include.
- "seedEmbeddingVocab-300-llvm12.txt" . You can get this from IR2Vec Source.
- "seedEmbeddingVocab-llvm14.txt" . You can get this from IR2Vec Source.

### In future we plan to automate wheel generation by integrating needed workflows in CI/CD pipeline. These wheels then will reflect changes in either IR2Vec or in LLVM project.

Expand Down
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,26 @@ Please see [here](https://compilers.cse.iith.ac.in/projects/ir2vec/) for more de

## Table Of Contents
- [IR2Vec](#ir2vec)
- [LLVM Version Archive](#llvm-version-archive)
- [Table Of Contents](#table-of-contents)
- [Installation](#installation)
- [LLVM Version Archive](#llvm-version-archive)
- [Table Of Contents](#table-of-contents)
- [Installation](#installation)
- [Python](#python)
- [C++](#cpp)
- [Requirements](#requirements)
- [Building from Source](#building-from-source)
- [Generating program representations](#generating-program-representations)
- [Using Binary](#using-binary)
- [Cpp](#cpp)
- [Requirements](#requirements)
- [Building from source](#building-from-source)
- [Generating program representations](#generating-program-representations)
- [Using Binary](#using-binary)
- [Command-Line options](#command-line-options)
- [Flow-Aware Embeddings](#flow-aware-embeddings)
- [Symbolic Embeddings](#symbolic-embeddings)
- [Using Libraries](#using-libraries)
- [Using Python package (IR2Vec-Wheels)](#using-python-package-ir2vec-wheels)
- [Experiments](#experiments)
- [Citation](#citation)
- [Contributions](#contributions)
- [License](#license)
- [Binaries, Libraries and Wheels - Artifacts](#binaries-libraries-and-wheels---artifacts)
- [Experiments](#experiments)
- [Note](#note)
- [Citation](#citation)
- [Contributions](#contributions)
- [License](#license)

## Installation

Expand Down Expand Up @@ -127,16 +132,16 @@ Please use `--help` for further details.
#### Flow-Aware Embeddings
For all functions
* `` ir2vec -fa -vocab vocabulary/seedEmbeddingVocab-300-llvm12.txt -o <output_file> -level <p|f> -class <class-number> <input_ll_file>``
* `` ir2vec -fa -vocab vocabulary/seedEmbeddingVocab-llvm14.txt -o <output_file> -level <p|f> -class <class-number> <input_ll_file>``

For a specific function
* `` ir2vec -fa -vocab vocabulary/seedEmbeddingVocab-300-llvm12.txt -o <output_file> -level f -class <class-number> -funcName=\<function-name\><input_ll_file>``
* `` ir2vec -fa -vocab vocabulary/seedEmbeddingVocab-llvm14.txt -o <output_file> -level f -class <class-number> -funcName=\<function-name\><input_ll_file>``

#### Symbolic Embeddings
For all functions
* `` ir2vec -sym -vocab vocabulary/seedEmbeddingVocab-300-llvm12.txt -o <output_file> -level <p|f> -class <class-number> <input_ll_file>``
* `` ir2vec -sym -vocab vocabulary/seedEmbeddingVocab-llvm14.txt -o <output_file> -level <p|f> -class <class-number> <input_ll_file>``
For a specific function
* `` ir2vec -sym -vocab vocabulary/seedEmbeddingVocab-300-llvm12.txt -o <output_file> -level f -class <class-number> -funcName=\<function-name\> <input_ll_file>``
* `` ir2vec -sym -vocab vocabulary/seedEmbeddingVocab-llvm14.txt -o <output_file> -level f -class <class-number> -funcName=\<function-name\> <input_ll_file>``

## Using Libraries
The libraries can be installed by passing the installation location to the `CMAKE_INSTALL_PREFIX` flag during `cmake` followed by `make install`.
Expand Down Expand Up @@ -165,7 +170,7 @@ The following example snippet shows how to query the exposed vector representati
// Creating object to generate FlowAware representation
auto ir2vec =
IR2Vec::Embeddings(<LLVM Module>, IR2Vec::IR2VecMode::FlowAware,
"./vocabulary/seedEmbeddingVocab-300-llvm12.txt");
"./vocabulary/seedEmbeddingVocab-llvm14.txt");

// Getting Instruction vectors corresponding to the instructions in <LLVM Module>
auto instVecMap = ir2vec.getInstVecMap();
Expand Down
94 changes: 47 additions & 47 deletions experiments/Device_Mapping/DevMap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,22 @@
"Accuracy Matrix: IR2Vec Vs. others\n",
"\n",
" Static Mapping Grewe et al. DeepTune NCC IR2Vec\n",
"AMD Tahiti 7970 58.823529 73.382353 83.676471 82.790 90.284006\n",
"NVIDIA GTX 970 56.911765 72.941176 80.294118 81.760 87.144993\n",
"Average 57.867647 73.161765 81.985294 82.275 88.714499\n",
"AMD Tahiti 7970 58.823529 73.382353 83.676471 82.790 91.766467\n",
"NVIDIA GTX 970 56.911765 72.941176 80.294118 81.760 86.976048\n",
"Average 57.867647 73.161765 81.985294 82.275 89.371257\n",
"\n",
"Speedup Matrix: IR2Vec Vs. others\n",
"\n",
" Static Mapping Grewe et al. DeepTune NCC IR2Vec\n",
"AMD Tahiti 7970 1.0 2.905822 3.335612 3.420 3.471963\n",
"NVIDIA GTX 970 1.0 1.264801 1.412222 1.390 1.433372\n",
"Average 1.0 2.085312 2.373917 2.405 2.452667\n"
"AMD Tahiti 7970 1.0 2.905822 3.335612 3.420 3.477054\n",
"NVIDIA GTX 970 1.0 1.264801 1.412222 1.390 1.453360\n",
"Average 1.0 2.085312 2.373917 2.405 2.465207\n"
]
}
],
"source": [
"raw_embeddings, fileIndexNum = readEmd_program(\n",
" \"./output/embeddings/Device_Mapping_Symbolic_llvm12.txt\"\n",
" \"./output/embeddings/Device_Mapping_Symbolic_llvm14.txt\"\n",
")\n",
"ir2vec_sym = evaluate(max_depth=10, learning_rate=0.5, n_estimators=70, seed=104)"
]
Expand Down Expand Up @@ -344,22 +344,22 @@
"Accuracy Matrix: IR2Vec Vs. others\n",
"\n",
" Static Mapping Grewe et al. DeepTune NCC IR2Vec\n",
"AMD Tahiti 7970 58.823529 73.382353 83.676471 82.790 92.825112\n",
"NVIDIA GTX 970 56.911765 72.941176 80.294118 81.760 89.686099\n",
"Average 57.867647 73.161765 81.985294 82.275 91.255605\n",
"AMD Tahiti 7970 58.823529 73.382353 83.676471 82.790 91.167665\n",
"NVIDIA GTX 970 56.911765 72.941176 80.294118 81.760 88.323353\n",
"Average 57.867647 73.161765 81.985294 82.275 89.745509\n",
"\n",
"Speedup Matrix: IR2Vec Vs. others\n",
"\n",
" Static Mapping Grewe et al. DeepTune NCC IR2Vec\n",
"AMD Tahiti 7970 1.0 2.905822 3.335612 3.420 3.510104\n",
"NVIDIA GTX 970 1.0 1.264801 1.412222 1.390 1.467221\n",
"Average 1.0 2.085312 2.373917 2.405 2.488663\n"
"AMD Tahiti 7970 1.0 2.905822 3.335612 3.420 3.450715\n",
"NVIDIA GTX 970 1.0 1.264801 1.412222 1.390 1.445097\n",
"Average 1.0 2.085312 2.373917 2.405 2.447906\n"
]
}
],
"source": [
"raw_embeddings, fileIndexNum = readEmd_program(\n",
" \"./output/embeddings/Device_Mapping_FlowAware_llvm12.txt\"\n",
" \"./output/embeddings/Device_Mapping_FlowAware_llvm14.txt\"\n",
")\n",
"ir2vec_fa = evaluate(max_depth=10, learning_rate=0.5, n_estimators=70, seed=104)"
]
Expand Down Expand Up @@ -468,8 +468,8 @@
"Geometric mean of Grewe et al. 1.22x\n",
"Geometric mean of DeepTune 1.46x\n",
"Geometric mean of Inst2Vec 1.40x\n",
"Geometric mean of IR2Vec Symbolic 1.559x\n",
"Geometric mean of IR2Vec Flow-Aware 1.581x\n"
"Geometric mean of IR2Vec Symbolic 1.566x\n",
"Geometric mean of IR2Vec Flow-Aware 1.552x\n"
]
}
],
Expand Down Expand Up @@ -498,8 +498,8 @@
"Geometric mean of Grewe et al. 1.11x\n",
"Geometric mean of DeepTune 1.21x\n",
"Geometric mean of Inst2Vec 1.21x\n",
"Geometric mean of IR2Vec Symbolic 1.237x\n",
"Geometric mean of IR2Vec Flow-Aware 1.261x\n"
"Geometric mean of IR2Vec Symbolic 1.248x\n",
"Geometric mean of IR2Vec Flow-Aware 1.258x\n"
]
}
],
Expand Down Expand Up @@ -528,8 +528,8 @@
"Geometric mean of Grewe et al. - 1.16x\n",
"Geometric mean of DeepTune - 1.33x\n",
"Geometric mean of Inst2Vec - 1.30x\n",
"Geometric mean of IR2Vec Symbolic 1.39x\n",
"Geometric mean of IR2Vec Flow-Aware 1.41x\n"
"Geometric mean of IR2Vec Symbolic 1.40x\n",
"Geometric mean of IR2Vec Flow-Aware 1.40x\n"
]
}
],
Expand Down Expand Up @@ -575,16 +575,16 @@
"text": [
"\n",
"AMD Tahiti 7970\n",
" % Increase in SpeedUp over Grewe et al - 29.65\n",
" % Increase in SpeedUp over DeepTune - 7.96\n",
" % Increase in SpeedUp over Inst2Vec - 12.95\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 1.43\n",
" % Increase in SpeedUp over Grewe et al - 27.27\n",
" % Increase in SpeedUp over DeepTune - 5.98\n",
" % Increase in SpeedUp over Inst2Vec - 10.88\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 0.86\n",
"\n",
"NVIDIA GTX 970\n",
" % Increase in SpeedUp over Grewe et al - 13.77\n",
" % Increase in SpeedUp over DeepTune - 4.31\n",
" % Increase in SpeedUp over Inst2Vec - 3.93\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 1.92\n"
" % Increase in SpeedUp over Grewe et al - 13.51\n",
" % Increase in SpeedUp over DeepTune - 4.07\n",
" % Increase in SpeedUp over Inst2Vec - 3.7\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 0.8\n"
]
}
],
Expand Down Expand Up @@ -693,8 +693,8 @@
"Accuracy of Grewe et al. 70.29%\n",
"Accuracy of DeepTune 83.24%\n",
"Accuracy of Inst2Vec 82.35%\n",
"Accuracy of IR2Vec Symbolic 90.284%\n",
"Accuracy of IR2Vec Flow-Aware 92.825%\n"
"Accuracy of IR2Vec Symbolic 91.766%\n",
"Accuracy of IR2Vec Flow-Aware 91.168%\n"
]
}
],
Expand All @@ -721,8 +721,8 @@
"Accuracy of Grewe et al. 74.56%\n",
"Accuracy of DeepTune 80.88%\n",
"Accuracy of Inst2Vec 82.65%\n",
"Accuracy of IR2Vec Symbolic 87.145%\n",
"Accuracy of IR2Vec Flow-Aware 89.686%\n"
"Accuracy of IR2Vec Symbolic 86.976%\n",
"Accuracy of IR2Vec Flow-Aware 88.323%\n"
]
}
],
Expand Down Expand Up @@ -757,11 +757,11 @@
"text": [
"\n",
"AMD Tahiti 7970\n",
" % Increase in SpeedUp over Grewe et al - 26.5\n",
" % Increase in SpeedUp over DeepTune - 10.93\n",
" % Increase in SpeedUp over Inst2Vec - 12.12\n",
" % Increase in SpeedUp over Inst2Vec-imm - 5.38\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 2.81\n"
" % Increase in SpeedUp over Grewe et al - 24.24\n",
" % Increase in SpeedUp over DeepTune - 8.95\n",
" % Increase in SpeedUp over Inst2Vec - 10.12\n",
" % Increase in SpeedUp over Inst2Vec-imm - 3.49\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 0.65\n"
]
}
],
Expand Down Expand Up @@ -801,11 +801,11 @@
"text": [
"\n",
"NVIDIA GTX 970\n",
" % Increase in SpeedUp over Grewe et al - 22.96\n",
" % Increase in SpeedUp over DeepTune - 11.7\n",
" % Increase in SpeedUp over Inst2Vec - 9.69\n",
" % Increase in SpeedUp over Inst2Vec - 3.54\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 2.92\n"
" % Increase in SpeedUp over Grewe et al - 21.09\n",
" % Increase in SpeedUp over DeepTune - 10.0\n",
" % Increase in SpeedUp over Inst2Vec - 8.03\n",
" % Increase in SpeedUp over Inst2Vec - 1.97\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 1.55\n"
]
}
],
Expand Down Expand Up @@ -845,10 +845,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
" % Increase in SpeedUp over DeepTune - 11.3\n",
" % Increase in SpeedUp over Inst2Vec - 10.92\n",
" % Increase in SpeedUp over Inst2Vec - 4.47\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 2.86\n"
" % Increase in SpeedUp over DeepTune - 9.46\n",
" % Increase in SpeedUp over Inst2Vec - 9.08\n",
" % Increase in SpeedUp over Inst2Vec - 2.74\n",
" % Increase in SpeedUp over IR2Vec Symbolic - 0.42\n"
]
}
],
Expand All @@ -871,7 +871,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand Down
Loading

0 comments on commit cb4c6a3

Please sign in to comment.