Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Llvm20upgrade #140

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
run: |
sudo python3 -m pip install lit
sudo python3 -m pip install filecheck
- name: Install LLVM-18
- name: Install LLVM-20
run: |
wget https://apt.llvm.org/llvm.sh
sudo bash llvm.sh 18
sudo bash llvm.sh 20
- uses: actions/checkout@v2
- name: Eigen-setup
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
run: |
sudo python3 -m pip install lit
sudo python3 -m pip install filecheck
- name: Install LLVM-19
- name: Install LLVM-20
run: |
wget https://apt.llvm.org/llvm.sh
sudo bash llvm.sh 19
sudo bash llvm.sh 20
- uses: actions/checkout@v2
- name: Eigen-setup
run: |
Expand Down
2 changes: 1 addition & 1 deletion Manylinux2014_Compliant_Source/manylinux-llvm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release -G Ninja -B build \
&& cmake --install build --prefix /root/destdir

WORKDIR /root/llvm
ARG LLVM_VERSION="18.1.8"
ARG LLVM_VERSION="20.1.0"
RUN wget -q "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/llvm-project-${LLVM_VERSION}.src.tar.xz" \
&& tar -xf "llvm-project-${LLVM_VERSION}.src.tar.xz"
WORKDIR /root/llvm/llvm-project-${LLVM_VERSION}.src/build
Expand Down
4 changes: 2 additions & 2 deletions Manylinux2014_Compliant_Source/pkg/regen-oracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cd src/test-suite

rm -rf oracle

SEED_VERSION="llvm19"
SEED_VERSION="llvm20"
SRC_WD="PE-benchmarks"
DEST_FOLDER_LL="PE-benchmarks-llfiles-${SEED_VERSION}"
DEST_FOLDER_SYM="oracle/SYM_${SEED_VERSION}_f"
Expand All @@ -18,7 +18,7 @@ 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-18 -S -emit-llvm -Xclang -disable-O0-optnone ${d} -o ${DEST_FOLDER_LL}/${oname}.ll &
name=$(basename ${d}) && oname=${name%.*} && clang-20 -S -emit-llvm -Xclang -disable-O0-optnone ${d} -o ${DEST_FOLDER_LL}/${oname}.ll &
done
wait

Expand Down
2 changes: 1 addition & 1 deletion Manylinux2014_Compliant_Source/pkg/tests/test_ir2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ABS_ACCURACY = 1e-4

TEST_SUITE_DIR = pl.Path(__file__).resolve().parents[3] / "src" / "test-suite"
SEED_VERSION = "llvm19"
SEED_VERSION = "llvm20"

ll_files = []
path = TEST_SUITE_DIR / f"index-{SEED_VERSION}.files"
Expand Down
59 changes: 32 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Please see [here](https://compilers.cse.iith.ac.in/projects/ir2vec/) for more de

> IR2Vec: LLVM IR Based Scalable Program Embeddings, S. VenkataKeerthy, Rohit Aggarwal, Shalini Jain, Maunendra Sankar Desarkar, Ramakrishna Upadrasta, and Y. N. Srikant

[![LLVM](https://img.shields.io/badge/LLVM-v19.1.7-blue)](https://github.com/llvm/llvm-project/releases/tag/llvmorg-19.1.7)
[![LLVM](https://img.shields.io/badge/LLVM-v20.1.0-blue)](https://github.com/llvm/llvm-project/releases/tag/llvmorg-20.1.0)
[![PyPI Version](https://img.shields.io/pypi/v/IR2Vec)](https://pypi.org/project/IR2Vec/)
![Tests](https://github.com/IITH-Compilers/IR2Vec/workflows/Tests/badge.svg)
![Publish](https://github.com/IITH-Compilers/IR2Vec/workflows/Publish/badge.svg)
Expand All @@ -18,7 +18,8 @@ Please see [here](https://compilers.cse.iith.ac.in/projects/ir2vec/) for more de

| LLVM Version | Branch |
| ------------ | ------ |
| LLVM 19.1.7 | [main](https://github.com/IITH-Compilers/IR2Vec) |
| LLVM 20.1.0 | [main](https://github.com/IITH-Compilers/IR2Vec) |
| LLVM 19.1.7 | [main](https://github.com/IITH-Compilers/IR2Vec/tree/llvm19) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main --> llvm19

| LLVM 18.1.8 | [llvm18](https://github.com/IITH-Compilers/IR2Vec/tree/llvm18) |
| LLVM 17.0.6 | [llvm17](https://github.com/IITH-Compilers/IR2Vec/tree/llvm17) |
| LLVM 16.0.1 | [llvm16](https://github.com/IITH-Compilers/IR2Vec/tree/llvm16) |
Expand All @@ -29,31 +30,31 @@ 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)
- [Python](#python)
- [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)
- [Initialization -ir2vec.initEmbedding](#initialization--ir2vecinitembedding)
- [getProgramVector](#getprogramvector)
- [getFunctionVectors](#getfunctionvectors)
- [getInstructionVectors](#getinstructionvectors)
- [Example](#example)
- [Binaries, Libraries and Wheels - Artifacts](#binaries-libraries-and-wheels---artifacts)
- [Experiments](#experiments)
- [Note](#note)
- [Citation](#citation)
- [Contributions](#contributions)
- [License](#license)
- [LLVM Version Archive](#llvm-version-archive)
- [Table Of Contents](#table-of-contents)
- [Installation](#installation)
- [Python](#python)
- [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)
- [Initialization -ir2vec.initEmbedding](#initialization--ir2vecinitembedding)
- [getProgramVector](#getprogramvector)
- [getFunctionVectors](#getfunctionvectors)
- [getInstructionVectors](#getinstructionvectors)
- [Example](#example)
- [Binaries, Libraries and Wheels - Artifacts](#binaries-libraries-and-wheels---artifacts)
- [Experiments](#experiments)
- [Note](#note)
- [Citation](#citation)
- [Contributions](#contributions)
- [License](#license)

## Installation

Expand All @@ -77,7 +78,11 @@ If you're a C++ developer and require low-level control, optimization, or integr
## Requirements
* cmake (>= 3.13.4)
* GNU Make (4.2.1)
<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix merge.

* LLVM (19.1.7) - [src](https://github.com/llvm/llvm-project/tree/release/17.x), [release](https://releases.llvm.org/download.html#19.1.7)
=======
* LLVM (20.1.0) - [src](https://github.com/llvm/llvm-project/tree/release/20.x), [release](https://releases.llvm.org/download.html#20.1.0)
>>>>>>> initial commit - change from llvm18 to llvm20
* Support for latest LLVM versions would be added soon
* Eigen library (3.3.7) (Optional)
* Python (3.6.7)
Expand Down
1 change: 1 addition & 0 deletions seed_embeddings/OpenKE/config/Trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(
self.analogies = analogy.AnalogyScorer(analogy_file=analogy_file)

def load_entity_names(self, index_dir):
print("Loading entity names...", index_dir)
with open(os.path.join(index_dir, "entity2id.txt")) as fEntity:
content = fEntity.read()

Expand Down
7 changes: 4 additions & 3 deletions seed_embeddings/OpenKE/generate_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def train(arg_conf):
alpha=0.00729,
opt_method="Adam",
checkpoint_dir=checkpoint_dir,
index_dir=arg_conf.index_dir,
)
trainer.run(
link_prediction=False,
Expand Down Expand Up @@ -137,10 +138,10 @@ def findRep(src, dest, index_dir):
metavar="DIRECTORY",
help="Location of the directory entity2id.txt, train2id.txt and relation2id.txt",
required=False,
default="../seed_embeddings/preprocessed/",
default="../preprocessed/",
)
parser.add_argument(
"--epoch", dest="epoch", help="Epochs", required=False, type=int, default=1000
"--epoch", dest="epoch", help="Epochs", required=False, type=int, default=20
)

parser.add_argument(
Expand Down Expand Up @@ -188,7 +189,7 @@ def findRep(src, dest, index_dir):
),
)

findRep(outfilejson, seedfile, arg_conf.index_dir)
findRep(outfile, seedfile, arg_conf.index_dir)

print("Training finished...")
print("seed file : ", seedfile)
11 changes: 8 additions & 3 deletions seed_embeddings/OpenKE/generate_embedding_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def reformat_embeddings(input_str):
metric = "loss"
mode = "min"

print(metric, mode)

scheduler = ASHAScheduler(
time_attr="training_iteration",
max_t=arg_conf.epoch,
Expand All @@ -270,11 +272,12 @@ def reformat_embeddings(input_str):
mode=mode,
)
optuna = OptunaSearch(metric="loss", mode="min")
print("GPU usage ", arg_conf.use_gpu)

if arg_conf.use_gpu:
train_with_resources = tune.with_resources(
tune.with_parameters(train, args=arg_conf),
resources={"cpu": 8, "gpu": 0.15},
resources={"cpu": 2, "gpu": 0.11},
)
else:
train_with_resources = tune.with_resources(
Expand All @@ -286,9 +289,9 @@ def reformat_embeddings(input_str):
param_space=search_space,
tune_config=TuneConfig(
search_alg=optuna,
max_concurrent_trials=12,
max_concurrent_trials=4,
scheduler=scheduler,
num_samples=128,
num_samples=16,
),
run_config=RunConfig(
storage_path=arg_conf.storage_path,
Expand Down Expand Up @@ -336,6 +339,7 @@ def reformat_embeddings(input_str):
# Construct the output file name using the best hyperparameters
outfile = os.path.join(
index_dir,
"embeddings/",
"seedEmbedding_{}_{}Dim_{}Alpha_{}batchsize_{}margin.ckpt".format(
metric,
dim,
Expand All @@ -357,6 +361,7 @@ def reformat_embeddings(input_str):

embeddings_path = os.path.join(
index_dir,
"embeddings/",
"seedEmbedding_{}_{}Dim_{}Alpha_{}batchsize_{}margin.ckpt".format(
metric,
dim,
Expand Down
4 changes: 4 additions & 0 deletions seed_embeddings/OpenKE/launch_training.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

python3 generate_embedding_ray.py --is_analogy True --use_gpu True --dim 75 --index_dir "/home/intern23002/iitH/ir2vec/IR2Vec/seed_embeddings/preprocessed" \
--analogy_file "/home/intern23002/iitH/ir2vec/IR2Vec/seed_embeddings/OpenKE/analogies.txt"
6 changes: 3 additions & 3 deletions seed_embeddings/triplets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [ -z $4 ]; then
exit
fi

LLVM_BUILD=$5
LLVM_BUILD=/usr

if [ -z $LLVM_BUILD ]; then
echo "5st arg should have a valid Build path"
Expand Down Expand Up @@ -70,13 +70,13 @@ while read p; do
fi
USED_OPT[$a]=$opt
DEBUG echo "opt from $opt"
${LLVM_BUILD}/bin/opt-19 -S -$opt $p -o $tmpfile
${LLVM_BUILD}/bin/opt-20 -S -$opt $p -o $tmpfile
$COLLECT_BUILD/bin/ir2vec -collectIR -o $4 $tmpfile &>/dev/null
let "a++"
rm "$tmpfile"
done &
if [ $counter == 100 ]; then
sleep 20
sleep 3
counter=0
fi

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if(NOT LLVM_IR2VEC)
set(LT_LLVM_INSTALL_DIR "" CACHE PATH "LLVM installation directory")
list(APPEND CMAKE_PREFIX_PATH "${LT_LLVM_INSTALL_DIR}/lib/cmake/llvm/")

find_package(LLVM 19.1.7 REQUIRED CONFIG)
find_package(LLVM 20.1.0 REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

Expand Down
4 changes: 2 additions & 2 deletions src/test-suite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ endif()

# sanity checks and lit configs
configure_file(sanity_check.sh.cmake sanity_check.sh @ONLY)
file(COPY PE-benchmarks-llfiles-llvm19 DESTINATION ./)
file(COPY PE-benchmarks-llfiles-llvm20 DESTINATION ./)
file(COPY sqlite3.ll DESTINATION ./)
file(COPY oracle DESTINATION ./)
file(COPY ../../vocabulary DESTINATION ./)
file(COPY index-llvm19.files DESTINATION ./)
file(COPY index-llvm20.files DESTINATION ./)


configure_file(lit.site.cfg.py.in lit.site.cfg.py @ONLY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; ModuleID = 'PE-benchmarks/Find_the_closest_pair_from_two_sorted_arrays.cpp'
source_filename = "PE-benchmarks/Find_the_closest_pair_from_two_sorted_arrays.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
target triple = "x86_64-pc-linux-gnu"

module asm ".globl _ZSt21ios_base_library_initv"

Expand Down Expand Up @@ -195,6 +195,6 @@ attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 2}
!5 = !{!"clang version 19.1.7 (https://github.com/llvm/llvm-project.git cd708029e0b2869e80abe31ddb175f7c35361f90)"}
!5 = !{!"Ubuntu clang version 20.1.0 (++20250204023448+d185bd94ff77-1~exp1~20250204023606.14)"}
!6 = distinct !{!6, !7}
!7 = !{!"llvm.loop.mustprogress"}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; ModuleID = 'PE-benchmarks/Iterative_QuickSort.cpp'
source_filename = "PE-benchmarks/Iterative_QuickSort.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
target triple = "x86_64-pc-linux-gnu"

module asm ".globl _ZSt21ios_base_library_initv"

Expand Down Expand Up @@ -319,7 +319,7 @@ attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 2}
!5 = !{!"clang version 19.1.7 (https://github.com/llvm/llvm-project.git cd708029e0b2869e80abe31ddb175f7c35361f90)"}
!5 = !{!"Ubuntu clang version 20.1.0 (++20250204023448+d185bd94ff77-1~exp1~20250204023606.14)"}
!6 = distinct !{!6, !7}
!7 = !{!"llvm.loop.mustprogress"}
!8 = distinct !{!8, !7}
Expand Down
Loading
Loading