-
Notifications
You must be signed in to change notification settings - Fork 7
Adding the dataset utlities for compiling files in parallel #36
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
Open
andrewkallai
wants to merge
9
commits into
llvm-ml:main
Choose a base branch
from
andrewkallai:outlier_tools
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1924028
Adding the dataset utlities for compiling files in parallel
7a39e15
Addressing comments to add generic thread, storage, and makefile argu…
andrewkallai f646086
Adding script to process output files and adding python files for gra…
andrewkallai 4cd5d30
Modified Python processing files for clarity and storage option. Modi…
andrewkallai d9b77b8
Removed python plot files and dataset download files to be moved into…
andrewkallai 4b4fb92
Adding IR feature count data collection features, as well as maxmium …
andrewkallai 6c2bf7c
Reformatted python files, changed how CSV fields are made in combine_…
andrewkallai d8a48c0
Fixing command to use CC var instead of clang.
andrewkallai 1cb7a74
Updated README and modified docstrings and code for improvement in wr…
andrewkallai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ llvm_ir_dataset_utils.egg-info/ | |
*.tar | ||
*.sif | ||
*.swp | ||
*~ | ||
25 changes: 25 additions & 0 deletions
25
llvm_ir_dataset_utils/compile_time_analysis_tools/Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
SHELL := /bin/bash | ||
|
||
WILD := $(shell echo {$(begin)..$(end)}) | ||
|
||
ifneq ($(CC), clang) | ||
$(warning WARNING: SETTING CC TO clang OR clang++) | ||
override CC := clang | ||
ifeq ($(lang), cpp) | ||
override CC := clang++ | ||
endif | ||
endif | ||
|
||
all: $(WILD) | ||
|
||
$(WILD): | ||
@perf stat --no-big-num -e instructions:u -o \ | ||
$(lang)/perf_stat_files/[email protected] \ | ||
$(CC) -O3 -c $(lang)/bc_files/[email protected] \ | ||
-o $(lang)/object_files/[email protected] | ||
@instruct=$$(awk '/instructions/ {print $$1}' \ | ||
$(lang)/perf_stat_files/[email protected]); \ | ||
echo "file$@, $$instruct" >> $(lang)/instruction_counts/[email protected] | ||
@size=$$(llvm-size $(lang)/object_files/[email protected] | awk 'NR==2 {print $$1}'); \ | ||
echo "file$@, $$size" >> $(lang)/textseg_sizes/[email protected] | ||
|
29 changes: 29 additions & 0 deletions
29
llvm_ir_dataset_utils/compile_time_analysis_tools/SLURM_files/batch_main_body.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
THREADS=24 | ||
andrewkallai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
BATCH=$(($SIZE/$SLURM_ARRAY_TASK_MAX)) | ||
I=$((${SLURM_ARRAY_TASK_ID}*${BATCH}+1+${START})) | ||
STOP=$(($I+${BATCH}-1)) | ||
if [ $SLURM_ARRAY_TASK_ID -eq $SLURM_ARRAY_TASK_MAX ]; then | ||
STOP=$(($I+${SIZE}%$SLURM_ARRAY_TASK_MAX-1)) | ||
fi | ||
cd $TMPDIR | ||
mkdir -p ir_bc_files/ps_$I/${TYPE} | ||
cd ir_bc_files/ps_$I/${TYPE} | ||
mkdir -p bc_files instruction_counts perf_stat_files \ | ||
textseg_sizes object_files | ||
eval tar --extract --file=${STORAGE}${TYPE}/${TYPE}_bc_files.tar \ | ||
bc_files/file{$I..$STOP}.bc | ||
cd $TMPDIR/ir_bc_files/ps_$I | ||
make --ignore-errors --makefile=${MAKE_PATH}Makefile \ | ||
--jobs=${THREADS} lang="${TYPE}" begin="$I" end="$STOP" | ||
mkdir -p ${STORAGE}${TYPE}/ps_$I | ||
> ${STORAGE}${TYPE}/ps_$I/text_segments.csv | ||
|
||
> ${STORAGE}${TYPE}/ps_$I/instructions.csv | ||
|
||
eval cat ${TYPE}/textseg_sizes/textseg{$I..$STOP}.csv \ | ||
>> ${STORAGE}${TYPE}/ps_$I/text_segments.csv | ||
eval cat ${TYPE}/instruction_counts/inst{$I..$STOP}.csv \ | ||
>> ${STORAGE}${TYPE}/ps_$I/instructions.csv | ||
cd .. | ||
rm -r ps_$I | ||
|
46 changes: 46 additions & 0 deletions
46
llvm_ir_dataset_utils/compile_time_analysis_tools/SLURM_files/create_batch_files.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
|
||
#USAGE | ||
#./create_batch_files.sh <STORAGE_PATH> <MAKEFILE_PATH> | ||
|
||
if [ -z "$1" ]; then | ||
STORAGE="/tmp" | ||
else | ||
STORAGE="$1" | ||
fi | ||
if [ -z "$2" ]; then | ||
MAKE_PATH=".." | ||
else | ||
MAKE_PATH="$2" | ||
fi | ||
|
||
lang=() | ||
start_ids=() | ||
sizes=() | ||
|
||
while IFS=',' read -r language start_index end_index; do | ||
lang+=($language) | ||
start_ids+=($start_index) | ||
sizes+=($((${end_index}-${start_index}))) | ||
done < <(tail -n +2 "../dataset_download/indices.csv") | ||
|
||
length=${#lang[@]} | ||
|
||
for (( i=0; i<$length; i++ )) | ||
do | ||
js="${lang[$i]}_batch.sh" | ||
cp job_template.sh $js | ||
echo "#SBATCH --output=${STORAGE}/${lang[$i]}/job_results/slurm-%A_%a.out" >> $js | ||
|
||
echo "#SBATCH --error=${STORAGE}/${lang[$i]}/job_results/slurm-%A_%a.out" >> $js | ||
|
||
echo "START=${start_ids[$i]}" >> $js | ||
echo "TYPE=${lang[$i]}" >> $js | ||
echo "SIZE=${sizes[$i]}" >> $js | ||
echo "STORAGE=${STORAGE}" >> $js | ||
echo "MAKE_PATH=${MAKE_PATH}" >> $js | ||
cat batch_main_body.sh >> $js | ||
chmod 744 $js | ||
done | ||
|
10 changes: 10 additions & 0 deletions
10
llvm_ir_dataset_utils/compile_time_analysis_tools/SLURM_files/job_template.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash -l | ||
# | ||
#SBATCH --nodes=1 --ntasks=1 --cpus-per-task=12 | ||
#SBATCH --job-name=compiler_batch | ||
#SBATCH --partition=standard | ||
#SBATCH --time=0-00:10:00 | ||
#SBATCH --export=NONE | ||
# NUMBER OF JOBS: 400 | ||
#SBATCH --array=0-399 | ||
|
44 changes: 44 additions & 0 deletions
44
llvm_ir_dataset_utils/compile_time_analysis_tools/combine_outputs.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
#Usage: | ||
#./combine_outputs.sh <language> [storage] | ||
|
||
if [ -z "$1" ]; then | ||
echo "Missing language argument." | ||
exit 1 | ||
else | ||
LANGUAGE="$1" | ||
fi | ||
|
||
if [ -z "$2" ]; then | ||
STORAGE="/tmp" | ||
else | ||
STORAGE="$2" | ||
fi | ||
|
||
|
||
cd ${STORAGE} | ||
|
||
echo "file, text_segment_size" \ | ||
> ${LANGUAGE}/results/${LANGUAGE}_text_segments.csv | ||
echo "file, instructions" \ | ||
> ${LANGUAGE}/results/${LANGUAGE}_instructions.csv | ||
for ps in ${LANGUAGE}/ps_*; do | ||
cat ${ps}/text_segments.csv \ | ||
>> ${LANGUAGE}/results/${LANGUAGE}_text_segments.csv | ||
cat ${ps}/instructions.csv \ | ||
>> ${LANGUAGE}/results/${LANGUAGE}_instructions.csv | ||
done | ||
sort -nk1.5 ${LANGUAGE}/results/${LANGUAGE}_text_segments.csv \ | ||
-o ${LANGUAGE}/results/${LANGUAGE}_text_segments.csv | ||
sort -nk1.5 ${LANGUAGE}/results/${LANGUAGE}_instructions.csv \ | ||
-o ${LANGUAGE}/results/${LANGUAGE}_instructions.csv | ||
awk -F, 'NR==FNR{a[NR]=$1","$2; next} {print a[FNR], $2}' \ | ||
OFS=, ${LANGUAGE}/results/${LANGUAGE}_text_segments.csv \ | ||
${LANGUAGE}/results/${LANGUAGE}_instructions.csv \ | ||
> ${LANGUAGE}/results/${LANGUAGE}_combined_results.csv | ||
sed -n -i '/, ,/!p' ${LANGUAGE}/results/${LANGUAGE}_combined_results.csv | ||
rm ${LANGUAGE}/results/${LANGUAGE}_instructions.csv \ | ||
${LANGUAGE}/results/${LANGUAGE}_text_segments.csv | ||
rm -r ${LANGUAGE}/ps_* | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.