Skip to content

Commit

Permalink
Upload SPEC test script
Browse files Browse the repository at this point in the history
  • Loading branch information
cla7aye15I4nd committed Jun 11, 2024
1 parent 8b3bfbc commit 42232b4
Show file tree
Hide file tree
Showing 11 changed files with 541 additions and 0 deletions.
37 changes: 37 additions & 0 deletions artifact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ docker run -it dataisland/shadowbound-seceval /bin/bash
/root/test.sh
```

After running the command, you should see the following output:

```shell
[+] 2017-9164-9166
[+] 2017-9167-9173
[+] CVE-2006-6563
[+] CVE-2009-2285
[+] CVE-2013-4243
[+] CVE-2013-7443
[+] CVE-2014-1912
[+] CVE-2015-8668
[+] CVE-2015-9101
[+] CVE-2016-10270
[+] CVE-2016-10271
...
```

#### 🔨 Build Image by Yourself

> [!WARNING]
Expand All @@ -83,3 +100,23 @@ docker run -it sec-eval /bin/bash
```

### ⚡ (Step 5) Performance Test

In this step, we demonstrate the performance of ShadowBound. You can use the following command to run the test:

#### 🖼️ Use Pre-built Image

```bash
docker pull dataisland/shadowbound-perfeval:latest
docker run -privileged -it dataisland/shadowbound-perfeval /bin/bash
python3 /root/scripts/spectest.py | tee /root/spectest.log
```

After running the command, you can the result at `/root/spectest.log`.

#### 🔨 Build Image by Yoursel

If you want to build the image by yourself, you need to download the SPEC CPU 2017 benchmark suite (`cpu2017.iso`) from the official website. Then, use the following command to build the image:

```bash
CPU2017_PATH=/path/to/cpu2017.iso artifact/spec2017/build.sh
```
1 change: 1 addition & 0 deletions artifact/spec2017/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.iso
7 changes: 7 additions & 0 deletions artifact/spec2017/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM shadowbound

COPY ./config /shadowbound/config
COPY ./artifact/spec2017/config /root/config
COPY ./artifact/spec2017/scripts /root/scripts

RUN cd /root/scripts && gcc -o spectest spectest.c && pip3 install prettytable numpy
16 changes: 16 additions & 0 deletions artifact/spec2017/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

CPU2017_PATH=${CPU2017_PATH:-$HOME/shadowbound/artifact/spec2017/cpu2017.iso}

if [ ! -f $CPU2017_PATH ]; then
echo "Please set CPU2017_PATH to the path of the SPEC CPU2017 ISO"
echo "If you do not have the ISO, please use our pre-built image"
exit 1
fi

CPU2017_DIR=`dirname $CPU2017_PATH`

docker compose up --build spec2017-eval
docker run --privileged -v $CPU2017_DIR:/cpu2017 -it spec2017-eval /root/scripts/start.sh
76 changes: 76 additions & 0 deletions artifact/spec2017/config/native.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
%ifndef %{label}
% define label "native"
%endif

%ifndef %{build_ncpus}
% define build_ncpus 8
%endif

command_add_redirect = 1
flagsurl = $[top]/config/flags/clang.xml
ignore_errors = 1
iterations = 1
label = %{label}
line_width = 1020
log_line_width = 1020
makeflags = --jobs=%{build_ncpus}
mean_anyway = 1
output_format = txt,csv
preenv = 1
reportable = 0
tune = peak

intrate,fprate:
copies = 1
intspeed,fpspeed:
threads = 1

default:
CC = /shadowbound/llvm-project/build/bin/clang -std=c99
CXX = /shadowbound/llvm-project/build/bin/clang++ -std=c++03

CC_VERSION_OPTION = --version
CXX_VERSION_OPTION = --version

default:
sw_base_ptrsize = 64-bit
sw_peak_ptrsize = 64-bit

any_fortran:
fail_build = 1

default:
EXTRA_PORTABILITY = -DSPEC_LP64

500.perlbench_r,600.perlbench_s:
%if %{bits} == 32
% define suffix IA32
%else
% define suffix X64
%endif
PORTABILITY = -DSPEC_LINUX_%{suffix}

502.gcc_r,602.gcc_s:
EXTRA_CFLAGS = -fno-strict-aliasing -fgnu89-inline

510.parest_r:
CXXPORTABILITY = -DSPEC_PAREST_STD_FLUSH_WORKAROUND=1

523.xalancbmk_r,623.xalancbmk_s:
CXXPORTABILITY = -DSPEC_LINUX

525.x264_r,625.x264_s:
PORTABILITY = -fcommon

526.blender_r:
PORTABILITY = -funsigned-char -DSPEC_LINUX
CXXPORTABILITY = -D__BOOL_DEFINED

default=base:
OPTIMIZE = -g -O1 -fno-slp-vectorize

default=peak:
OPTIMIZE = -g -O1 -fno-slp-vectorize

default:
sw_compiler001 = Clang 15
113 changes: 113 additions & 0 deletions artifact/spec2017/config/shadowbound.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
%ifndef %{label}
% define label "shadowbound"
%endif

%ifndef %{build_ncpus}
% define build_ncpus 8
%endif

command_add_redirect = 1
flagsurl = $[top]/config/flags/clang.xml
ignore_errors = 1
iterations = 1
label = %{label}
line_width = 1020
log_line_width = 1020
makeflags = --jobs=%{build_ncpus}
mean_anyway = 1
output_format = txt,csv
preenv = 1
reportable = 0
tune = peak

intrate,fprate:
copies = 1
intspeed,fpspeed:
threads = 1

default:
CC = /shadowbound/llvm-project/build/bin/clang -std=c99 -fsanitize=overflow-defense -mllvm -odef-whitelist=/root/cpu2017/whitelist.txt
CXX = /shadowbound/llvm-project/build/bin/clang++ -std=c++03 -fsanitize=overflow-defense -mllvm -odef-whitelist=/root/cpu2017/whitelist.txt

CC_VERSION_OPTION = --version
CXX_VERSION_OPTION = --version

default:
sw_base_ptrsize = 64-bit
sw_peak_ptrsize = 64-bit

any_fortran:
fail_build = 1

default:
EXTRA_PORTABILITY = -DSPEC_LP64

500.perlbench_r,600.perlbench_s:
%if %{bits} == 32
% define suffix IA32
%else
% define suffix X64
%endif
PORTABILITY = -DSPEC_LINUX_%{suffix}
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/500.perlbench_r.json -mllvm -odef-perf-test=1

502.gcc_r,602.gcc_s:
EXTRA_CFLAGS = -fno-strict-aliasing -fgnu89-inline -mllvm -odef-pattern-opt-file=/shadowbound/config/502.gcc_r.json -mllvm -odef-perf-test=1

505.mcf_r,605.mcf_s:
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/505.mcf_r.json

508.namd_r:
EXTRA_CXXFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/508.namd_r.json -mllvm -odef-perf-test=1

510.parest_r:
CXXPORTABILITY = -DSPEC_PAREST_STD_FLUSH_WORKAROUND=1
EXTRA_CXXFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/510.parest_r.json -mllvm -odef-perf-test=1

511.povray_r:
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/511.povray_r.json
EXTRA_CXXFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/511.povray_r.json

519.lbm_r,619.lbm_s:
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/519.lbm_r.json

520.omnetpp_r,620.omnetpp_s:
EXTRA_CXXFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/520.omnetpp_r.json

523.xalancbmk_r,623.xalancbmk_s:
CXXPORTABILITY = -DSPEC_LINUX
EXTRA_CXXFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/523.xalancbmk_r.json -mllvm -odef-perf-test=1

525.x264_r,625.x264_s:
PORTABILITY = -fcommon
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/525.x264_r.json

526.blender_r:
PORTABILITY = -funsigned-char -DSPEC_LINUX
CXXPORTABILITY = -D__BOOL_DEFINED
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/526.blender_r.json
EXTRA_CXXFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/526.blender_r.json

531.deepsjeng_r,631.deepsjeng_s:
EXTRA_CXXFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/531.deepsjeng_r.json

538.imagick_r,638.imagick_s:
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/538.imagick_r.json

541.leela_r,641.leela_s:
EXTRA_CXXFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/541.leela_r.json

544.nab_r,644.nab_s:
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/544.nab_r.json

557.xz_r,657.xz_s:
EXTRA_CFLAGS = -mllvm -odef-pattern-opt-file=/shadowbound/config/557.xz_r.json

default=base:
OPTIMIZE = -g -O1 -fno-slp-vectorize

default=peak:
OPTIMIZE = -g -O1 -fno-slp-vectorize

default:
sw_compiler001 = Clang 15
53 changes: 53 additions & 0 deletions artifact/spec2017/config/whitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 500.perlbench_r
S_nextchar
Perl_regexec_flags

# 503.gcc_r
lex_string
bitmap_obstack_release
c_parse_file
sra_deinitialize
free_scc_vn
free_vn_table
execute_rtl_pre
execute_rtl_cprop
rest_of_handle_gcse2
run_scc_vn
free_aux_for_blocks
free_aux_for_edges

# 526.blender_r
polyfill_prepare

# 508.namd_r
_ZN20ComputeNonbondedUtil9calc_selfEP9nonbonded
_ZN20ComputeNonbondedUtil38calc_self_energy_merge_fullelect_pprofEP9nonbonded
_ZN20ComputeNonbondedUtil37calc_self_energy_slow_fullelect_pprofEP9nonbonded
_ZN20ComputeNonbondedUtil36calc_self_energy_merge_fullelect_lesEP9nonbonded
_ZN20ComputeNonbondedUtil36calc_self_energy_merge_fullelect_intEP9nonbonded
_ZN20ComputeNonbondedUtil36calc_self_energy_merge_fullelect_fepEP9nonbonded
_ZN20ComputeNonbondedUtil35calc_self_energy_slow_fullelect_lesEP9nonbonded
_ZN20ComputeNonbondedUtil35calc_self_energy_slow_fullelect_fepEP9nonbonded
_ZN20ComputeNonbondedUtil32calc_self_energy_merge_fullelectEP9nonbonded
_ZN20ComputeNonbondedUtil32calc_self_energy_fullelect_pprofEP9nonbonded
_ZN20ComputeNonbondedUtil31calc_self_merge_fullelect_pprofEP9nonbonded
_ZN20ComputeNonbondedUtil31calc_self_energy_slow_fullelectEP9nonbonded
_ZN20ComputeNonbondedUtil30calc_self_slow_fullelect_pprofEP9nonbonded
_ZN20ComputeNonbondedUtil30calc_self_energy_fullelect_lesEP9nonbonded
_ZN20ComputeNonbondedUtil30calc_self_energy_fullelect_intEP9nonbonded
_ZN20ComputeNonbondedUtil30calc_self_energy_fullelect_fepEP9nonbonded
_ZN20ComputeNonbondedUtil29calc_self_merge_fullelect_lesEP9nonbonded
_ZN20ComputeNonbondedUtil28calc_self_slow_fullelect_lesEP9nonbonded
_ZN20ComputeNonbondedUtil26calc_self_energy_fullelectEP9nonbonded
_ZN20ComputeNonbondedUtil25calc_self_merge_fullelectEP9nonbonded
_ZN20ComputeNonbondedUtil25calc_self_fullelect_pprofEP9nonbonded
_ZN20ComputeNonbondedUtil24calc_self_slow_fullelectEP9nonbonded
_ZN20ComputeNonbondedUtil23calc_self_fullelect_lesEP9nonbonded
_ZN20ComputeNonbondedUtil22calc_self_energy_pprofEP9nonbonded
_ZN20ComputeNonbondedUtil20calc_self_energy_lesEP9nonbonded
_ZN20ComputeNonbondedUtil20calc_self_energy_intEP9nonbonded
_ZN20ComputeNonbondedUtil20calc_self_energy_fepEP9nonbonded
_ZN20ComputeNonbondedUtil19calc_self_fullelectEP9nonbonded
_ZN20ComputeNonbondedUtil16calc_self_energyEP9nonbonded
_ZN20ComputeNonbondedUtil15calc_self_pprofEP9nonbonded
_ZN20ComputeNonbondedUtil13calc_self_lesEP9nonbonded
72 changes: 72 additions & 0 deletions artifact/spec2017/scripts/spectest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include <stdio.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>

struct rusage rusage;
struct timeval start, end;
pid_t pid;

static inline int run(const char *file, char *const *argv)
{
pid_t pid = fork();
if (pid == 0)
{
freopen("/dev/null", "w", stdout);
freopen("/dev/null", "w", stderr);
execvp(file, argv);
exit(-1);
}
else if (pid > 0)
{
int status;
wait4(pid, &status, 0, &rusage);
gettimeofday(&end, NULL);
return status;
}
else
{
perror("fork");
return 1;
}
}

int main(int argc, char *argv[])
{
if (argc < 2)
{
printf("Usage: exe_file args\n");
printf("e.g: perlbench_s -I./lib checkspam.pl 2500 5 25 11 150 1 1 1 1\n");
return 1;
}

int time_used, cpu_time_used, memory_used, signum;

gettimeofday(&start, NULL);

int ret = run(argv[1], (char *const *)&argv[1]);
signum = WEXITSTATUS(ret);

time_used = (int)(end.tv_sec * 1000 + end.tv_usec / 1000 - start.tv_sec * 1000 -
start.tv_usec / 1000);
cpu_time_used =
rusage.ru_utime.tv_sec * 1000 + rusage.ru_utime.tv_usec / 1000 +
rusage.ru_stime.tv_sec * 1000 + rusage.ru_stime.tv_usec / 1000;

memory_used = rusage.ru_maxrss;

printf("time: %6d ms\n", time_used);
printf("memory: %6d kb\n", memory_used);
printf("exit: %6d\n", signum);
fflush(stdout);

return 0;
}
Loading

0 comments on commit 42232b4

Please sign in to comment.