Skip to content

Commit 2f01cb7

Browse files
Enable static PGO for Linux SGX (#2270)
Enable static PGO for Linux SGX and update the related benchmarks test scripts and documents.
1 parent cabcb17 commit 2f01cb7

File tree

15 files changed

+209
-15
lines changed

15 files changed

+209
-15
lines changed

product-mini/platforms/linux-sgx/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ if (NOT DEFINED WAMR_BUILD_SGX_IPFS)
8989
set (WAMR_BUILD_SGX_IPFS 0)
9090
endif ()
9191

92+
if (NOT DEFINED WAMR_BUILD_STATIC_PGO)
93+
# Disable static PGO by default
94+
set (WAMR_BUILD_STATIC_PGO 0)
95+
endif ()
96+
9297
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
9398
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 -ffunction-sections -fdata-sections \
9499
-Wall -Wno-unused-parameter -Wno-pedantic \
@@ -107,6 +112,18 @@ add_custom_command (
107112

108113
add_custom_target (vmlib_untrusted ALL DEPENDS libvmlib_untrusted.a)
109114

115+
if ((WAMR_BUILD_STATIC_PGO EQUAL 1) AND (WAMR_BUILD_AOT EQUAL 1))
116+
execute_process(
117+
COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_STATIC_PGO = 0/WAMR_BUILD_STATIC_PGO = 1/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile"
118+
OUTPUT_VARIABLE cmdOutput
119+
)
120+
else()
121+
execute_process(
122+
COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_STATIC_PGO = 1/WAMR_BUILD_STATIC_PGO = 0/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile"
123+
OUTPUT_VARIABLE cmdOutput
124+
)
125+
endif()
126+
110127
if (DEFINED WAMR_BUILD_GLOBAL_HEAP_POOL)
111128
execute_process(
112129
COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_GLOBAL_HEAP_POOL = .*/WAMR_BUILD_GLOBAL_HEAP_POOL = ${WAMR_BUILD_GLOBAL_HEAP_POOL}/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile"

product-mini/platforms/linux-sgx/enclave-sample/App/App.cpp

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ print_help()
232232
printf(" for example:\n");
233233
printf(" --addr-pool=1.2.3.4/15,2.3.4.5/16\n");
234234
printf(" --max-threads=n Set maximum thread number per cluster, default is 4\n");
235+
#if WASM_ENABLE_STATIC_PGO != 0
236+
printf(" --gen-prof-file=<path> Generate LLVM PGO (Profile-Guided Optimization) profile file\n");
237+
#endif
235238
printf(" --version Show version information\n");
236239
return 1;
237240
}
@@ -294,6 +297,10 @@ typedef enum EcallCmd {
294297
CMD_SET_WASI_ARGS, /* wasm_runtime_set_wasi_args() */
295298
CMD_SET_LOG_LEVEL, /* bh_log_set_verbose_level() */
296299
CMD_GET_VERSION, /* wasm_runtime_get_version() */
300+
#if WASM_ENABLE_STATIC_PGO != 0
301+
CMD_GET_PGO_PROF_BUF_SIZE, /* wasm_runtime_get_pro_prof_data_size() */
302+
CMD_DUMP_PGO_PROF_BUF_DATA, /* wasm_runtime_dump_pgo_prof_data_to_buf() */
303+
#endif
297304
} EcallCmd;
298305

299306
static void
@@ -598,6 +605,64 @@ get_version(uint64_t *major, uint64_t *minor, uint64_t *patch)
598605
*patch = ecall_args[2];
599606
}
600607

608+
#if WASM_ENABLE_STATIC_PGO != 0
609+
static void
610+
dump_pgo_prof_data(void *module_inst, const char *path)
611+
{
612+
char *buf;
613+
uint32_t len;
614+
FILE *file;
615+
616+
uint64_t ecall_args[1];
617+
ecall_args[0] = (uint64_t)(uintptr_t)module_inst;
618+
if (SGX_SUCCESS
619+
!= ecall_handle_command(g_eid, CMD_GET_PGO_PROF_BUF_SIZE,
620+
(uint8_t *)ecall_args, sizeof(ecall_args))) {
621+
printf("Call ecall_handle_command() failed.\n");
622+
return;
623+
}
624+
if (!(len = ecall_args[0])) {
625+
printf("failed to get LLVM PGO profile data size\n");
626+
return;
627+
}
628+
629+
if (!(buf = (char *)malloc(len))) {
630+
printf("allocate memory failed\n");
631+
return;
632+
}
633+
634+
uint64_t ecall_args_2[3];
635+
ecall_args_2[0] = (uint64_t)(uintptr_t)module_inst;
636+
ecall_args_2[1] = (uint64_t)(uintptr_t)buf;
637+
ecall_args_2[2] = len;
638+
if (SGX_SUCCESS
639+
!= ecall_handle_command(g_eid, CMD_DUMP_PGO_PROF_BUF_DATA,
640+
(uint8_t *)ecall_args_2,
641+
sizeof(ecall_args_2))) {
642+
printf("Call ecall_handle_command() failed.\n");
643+
free(buf);
644+
return;
645+
}
646+
if (!(len = ecall_args_2[0])) {
647+
printf("failed to dump LLVM PGO profile data\n");
648+
free(buf);
649+
return;
650+
}
651+
652+
if (!(file = fopen(path, "wb"))) {
653+
printf("failed to create file %s", path);
654+
free(buf);
655+
return;
656+
}
657+
fwrite(buf, len, 1, file);
658+
fclose(file);
659+
660+
free(buf);
661+
662+
printf("LLVM raw profile file %s was generated.\n", path);
663+
}
664+
#endif
665+
601666
int
602667
main(int argc, char *argv[])
603668
{
@@ -619,6 +684,9 @@ main(int argc, char *argv[])
619684
const char *addr_pool[8] = { NULL };
620685
uint32_t addr_pool_size = 0;
621686
uint32_t max_thread_num = 4;
687+
#if WASM_ENABLE_STATIC_PGO != 0
688+
const char *gen_prof_file = NULL;
689+
#endif
622690

623691
if (enclave_init(&g_eid) < 0) {
624692
std::cout << "Fail to initialize enclave." << std::endl;
@@ -718,6 +786,13 @@ main(int argc, char *argv[])
718786
return print_help();
719787
max_thread_num = atoi(argv[0] + 14);
720788
}
789+
#if WASM_ENABLE_STATIC_PGO != 0
790+
else if (!strncmp(argv[0], "--gen-prof-file=", 16)) {
791+
if (argv[0][16] == '\0')
792+
return print_help();
793+
gen_prof_file = argv[0] + 16;
794+
}
795+
#endif
721796
else if (!strncmp(argv[0], "--version", 9)) {
722797
uint64_t major = 0, minor = 0, patch = 0;
723798
get_version(&major, &minor, &patch);
@@ -779,6 +854,11 @@ main(int argc, char *argv[])
779854
else
780855
app_instance_main(wasm_module_inst, argc, argv);
781856

857+
#if WASM_ENABLE_STATIC_PGO != 0
858+
if (gen_prof_file)
859+
dump_pgo_prof_data(wasm_module_inst, gen_prof_file);
860+
#endif
861+
782862
ret = 0;
783863

784864
/* Deinstantiate module */
@@ -836,7 +916,7 @@ wamr_pal_create_process(struct wamr_pal_create_process_args *args)
836916
int stdoutfd = -1;
837917
int stderrfd = -1;
838918

839-
int argc = 2;
919+
const int argc = 2;
840920
char *argv[argc] = { (char *)"./iwasm", (char *)args->argv[0] };
841921

842922
uint8_t *wasm_files_buf = NULL;

product-mini/platforms/linux-sgx/enclave-sample/Enclave/Enclave.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ typedef enum EcallCmd {
4949
CMD_SET_WASI_ARGS, /* wasm_runtime_set_wasi_args() */
5050
CMD_SET_LOG_LEVEL, /* bh_log_set_verbose_level() */
5151
CMD_GET_VERSION, /* wasm_runtime_get_version() */
52+
#if WASM_ENABLE_STATIC_PGO != 0
53+
CMD_GET_PGO_PROF_BUF_SIZE, /* wasm_runtime_get_pro_prof_data_size() */
54+
CMD_DUMP_PGO_PROF_BUF_DATA, /* wasm_runtime_dump_pgo_prof_data_to_buf() */
55+
#endif
5256
} EcallCmd;
5357

5458
typedef struct EnclaveModule {
@@ -597,6 +601,36 @@ handle_cmd_get_version(uint64 *args, uint32 argc)
597601
args[2] = patch;
598602
}
599603

604+
#if WASM_ENABLE_STATIC_PGO != 0
605+
static void
606+
handle_cmd_get_pgo_prof_buf_size(uint64 *args, int32 argc)
607+
{
608+
wasm_module_inst_t module_inst = *(wasm_module_inst_t *)args;
609+
uint32 buf_len;
610+
611+
bh_assert(argc == 1);
612+
613+
buf_len = wasm_runtime_get_pgo_prof_data_size(module_inst);
614+
args[0] = buf_len;
615+
}
616+
617+
static void
618+
handle_cmd_get_pro_prof_buf_data(uint64 *args, int32 argc)
619+
{
620+
uint64 *args_org = args;
621+
wasm_module_inst_t module_inst = *(wasm_module_inst_t *)args++;
622+
char *buf = *(char **)args++;
623+
uint32 len = *(uint32 *)args++;
624+
uint32 bytes_dumped;
625+
626+
bh_assert(argc == 3);
627+
628+
bytes_dumped =
629+
wasm_runtime_dump_pgo_prof_data_to_buf(module_inst, buf, len);
630+
args_org[0] = bytes_dumped;
631+
}
632+
#endif
633+
600634
void
601635
ecall_handle_command(unsigned cmd, unsigned char *cmd_buf,
602636
unsigned cmd_buf_size)
@@ -647,6 +681,14 @@ ecall_handle_command(unsigned cmd, unsigned char *cmd_buf,
647681
case CMD_GET_VERSION:
648682
handle_cmd_get_version(args, argc);
649683
break;
684+
#if WASM_ENABLE_STATIC_PGO != 0
685+
case CMD_GET_PGO_PROF_BUF_SIZE:
686+
handle_cmd_get_pgo_prof_buf_size(args, argc);
687+
break;
688+
case CMD_DUMP_PGO_PROF_BUF_DATA:
689+
handle_cmd_get_pro_prof_buf_data(args, argc);
690+
break;
691+
#endif
650692
default:
651693
LOG_ERROR("Unknown command %d\n", cmd);
652694
break;

product-mini/platforms/linux-sgx/enclave-sample/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ WAMR_BUILD_SGX_IPFS = 0
1515
WAMR_BUILD_LIB_RATS = 0
1616
WAMR_BUILD_GLOBAL_HEAP_POOL = 0
1717
WAMR_BUILD_GLOBAL_HEAP_SIZE = 10485760
18+
WAMR_BUILD_STATIC_PGO = 0
1819

1920
VMLIB_BUILD_DIR ?= $(CURDIR)/../build
2021
LIB_RATS_SRC ?= $(VMLIB_BUILD_DIR)/_deps/librats-build
@@ -65,7 +66,7 @@ ifeq ($(WAMR_BUILD_LIB_RATS), 1)
6566
App_Include_Paths += -I$(LIB_RATS_INCLUDE_DIR)
6667
endif
6768

68-
App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths)
69+
App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) -DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO)
6970

7071
# Three configuration modes - Debug, prerelease, release
7172
# Debug - Macro DEBUG enabled.
@@ -134,7 +135,7 @@ ifeq ($(WAMR_BUILD_LIB_RATS), 1)
134135
Enclave_Include_Paths += -I$(LIB_RATS_INCLUDE_DIR) -I$(SGX_SSL)/include
135136
endif
136137

137-
Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths) -DWASM_GLOBAL_HEAP_SIZE=$(WAMR_BUILD_GLOBAL_HEAP_SIZE) -DWASM_ENABLE_GLOBAL_HEAP_POOL=$(WAMR_BUILD_GLOBAL_HEAP_POOL) -DWASM_ENABLE_LIB_RATS=$(WAMR_BUILD_LIB_RATS)
138+
Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths) -DWASM_GLOBAL_HEAP_SIZE=$(WAMR_BUILD_GLOBAL_HEAP_SIZE) -DWASM_ENABLE_GLOBAL_HEAP_POOL=$(WAMR_BUILD_GLOBAL_HEAP_POOL) -DWASM_ENABLE_LIB_RATS=$(WAMR_BUILD_LIB_RATS) -DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO)
138139
ifeq ($(SPEC_TEST), 1)
139140
Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=1
140141
else

tests/benchmarks/coremark/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ And then run `./build.sh` to build the source code, file `coremark.exe`, `corema
1919
Run `./run.sh` to test the benchmark, the native mode, iwasm aot mode and iwasm interpreter mode will be tested respectively.
2020

2121
Run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled, please refer [here](../README.md#install-llvm-profdata) to install tool `llvm-profdata` and build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`.
22+
23+
- For Linux, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled.
24+
25+
- For Linux-sgx, similarly, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then `make` in the directory `enclave-sample`. And run `./test_pgo.sh --sgx` to test the benchmark.

tests/benchmarks/coremark/test_pgo.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55

66
PLATFORM=$(uname -s | tr A-Z a-z)
77

8-
IWASM="../../../product-mini/platforms/${PLATFORM}/build/iwasm"
9-
WAMRC="../../../wamr-compiler/build/wamrc"
8+
if [ "$1" = "--sgx" ] && [ "$PLATFORM" = "linux" ]; then
9+
IWASM="../../../product-mini/platforms/${PLATFORM}-sgx/enclave-sample/iwasm"
10+
WAMRC="../../../wamr-compiler/build/wamrc -sgx"
11+
else
12+
IWASM="../../../product-mini/platforms/${PLATFORM}/build/iwasm"
13+
WAMRC="../../../wamr-compiler/build/wamrc"
14+
fi
1015

1116
if [ ! -e "coremark.wasm" ]; then
1217
echo "coremark.wasm doesn't exist, please run build.sh first"

tests/benchmarks/dhrystone/test_pgo.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55

66
PLATFORM=$(uname -s | tr A-Z a-z)
77

8-
IWASM="../../../product-mini/platforms/${PLATFORM}/build/iwasm"
9-
WAMRC="../../../wamr-compiler/build/wamrc"
8+
if [ "$1" = "--sgx" ] && [ "$PLATFORM" = "linux" ]; then
9+
IWASM="../../../product-mini/platforms/${PLATFORM}-sgx/enclave-sample/iwasm"
10+
WAMRC="../../../wamr-compiler/build/wamrc -sgx"
11+
else
12+
IWASM="../../../product-mini/platforms/${PLATFORM}/build/iwasm"
13+
WAMRC="../../../wamr-compiler/build/wamrc"
14+
fi
1015

1116
if [ ! -e "dhrystone.wasm" ]; then
1217
echo "dhrystone.wasm doesn't exist, please run build.sh first"

tests/benchmarks/jetstream/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ And then run `./build.sh` to build the source code, the folder `out` will be cre
2929
Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated.
3030

3131
Run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled, please refer [here](../README.md#install-llvm-profdata) to install tool `llvm-profdata` and build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`.
32+
33+
- For Linux, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled.
34+
35+
- For Linux-sgx, similarly, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then `make` in the directory `enclave-sample`. And run `./test_pgo.sh --sgx` to test the benchmark.

tests/benchmarks/jetstream/test_pgo.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ REPORT=$CUR_DIR/report.txt
99
TIME=/usr/bin/time
1010

1111
PLATFORM=$(uname -s | tr A-Z a-z)
12-
IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
13-
WAMRC_CMD=$CUR_DIR/../../../wamr-compiler/build/wamrc
12+
if [ "$1" = "--sgx" ] && [ "$PLATFORM" = "linux" ]; then
13+
IWASM_CMD="$CUR_DIR/../../../product-mini/platforms/${PLATFORM}-sgx/enclave-sample/iwasm"
14+
WAMRC_CMD="$CUR_DIR/../../../wamr-compiler/build/wamrc -sgx"
15+
else
16+
IWASM_CMD="$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm"
17+
WAMRC_CMD="$CUR_DIR/../../../wamr-compiler/build/wamrc"
18+
fi
1419

1520
BENCH_NAME_MAX_LEN=20
1621

tests/benchmarks/libsodium/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ And then run `./build.sh` to build the source code, the libsodium source code wi
1818

1919
Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested respectively.
2020

21+
Run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled, please refer [here](../README.md#install-llvm-profdata) to install tool `llvm-profdata` and build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`.
22+
23+
- For Linux, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled.
24+
25+
- For Linux-sgx, similarly, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then `make` in the directory `enclave-sample`. And run `./test_pgo.sh --sgx` to test the benchmark.
26+
2127
# Others
2228

2329
Refer to [Performance of WebAssembly runtimes in 2023](https://00f.net/2023/01/04/webassembly-benchmark-2023) for more about the performance comparison of wasm runtimes on running the libsodium benchmarks.

tests/benchmarks/libsodium/test_pgo.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ PLATFORM=$(uname -s | tr A-Z a-z)
1919

2020
readonly OUT_DIR=$PWD/libsodium/zig-out/bin
2121
readonly REPORT=$PWD/report.txt
22-
readonly IWASM_CMD=$PWD/../../../product-mini/platforms/${PLATFORM}/build/iwasm
23-
readonly WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
22+
if [ "$1" = "--sgx" ] && [ "$PLATFORM" = "linux" ]; then
23+
readonly IWASM_CMD="$PWD/../../../product-mini/platforms/${PLATFORM}-sgx/enclave-sample/iwasm"
24+
readonly WAMRC_CMD="$PWD/../../../wamr-compiler/build/wamrc -sgx"
25+
else
26+
readonly IWASM_CMD="$PWD/../../../product-mini/platforms/${PLATFORM}/build/iwasm"
27+
readonly WAMRC_CMD="$PWD/../../../wamr-compiler/build/wamrc"
28+
fi
2429
readonly TIME=/usr/bin/time
2530

2631
BENCH_NAME_MAX_LEN=20

tests/benchmarks/polybench/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ And then run `./build.sh` to build the source code, the folder `out` will be cre
1919
Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated.
2020

2121
Run `./run_interp.sh` to test the benchmark, the native mode and iwasm interpreter mode will be tested for each workload, and the file `report.txt` will be generated.
22+
23+
Run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled, please refer [here](../README.md#install-llvm-profdata) to install tool `llvm-profdata` and build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`.
24+
25+
- For Linux, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled.
26+
27+
- For Linux-sgx, similarly, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then `make` in the directory `enclave-sample`. And run `./test_pgo.sh --sgx` to test the benchmark.

tests/benchmarks/polybench/test_pgo.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ REPORT=$CUR_DIR/report.txt
99
TIME=/usr/bin/time
1010

1111
PLATFORM=$(uname -s | tr A-Z a-z)
12-
IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
13-
WAMRC_CMD=$CUR_DIR/../../../wamr-compiler/build/wamrc
12+
if [ "$1" = "--sgx" ] && [ "$PLATFORM" = "linux" ]; then
13+
IWASM_CMD="$CUR_DIR/../../../product-mini/platforms/${PLATFORM}-sgx/enclave-sample/iwasm"
14+
WAMRC_CMD="$CUR_DIR/../../../wamr-compiler/build/wamrc -sgx"
15+
else
16+
IWASM_CMD="$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm"
17+
WAMRC_CMD="$CUR_DIR/../../../wamr-compiler/build/wamrc"
18+
fi
1419

1520
BENCH_NAME_MAX_LEN=20
1621

tests/benchmarks/sightglass/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode wil
2121
Run `./run_interp.sh` to test the benchmark, the native mode and iwasm interpreter mode will be tested for each workload, and the file `report.txt` will be generated.
2222

2323
Run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled, please refer [here](../README.md#install-llvm-profdata) to install tool `llvm-profdata` and build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`.
24+
25+
- For Linux, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then run `./test_pgo.sh` to test the benchmark with AOT static PGO (Profile-Guided Optimization) enabled.
26+
27+
- For Linux-sgx, similarly, build `iwasm` with `cmake -DWAMR_BUILD_STATIC_PGO=1`, then `make` in the directory `enclave-sample`. And run `./test_pgo.sh --sgx` to test the benchmark.

tests/benchmarks/sightglass/test_pgo.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ REPORT=$CUR_DIR/report.txt
99
TIME=/usr/bin/time
1010

1111
PLATFORM=$(uname -s | tr A-Z a-z)
12-
IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
13-
WAMRC_CMD=$CUR_DIR/../../../wamr-compiler/build/wamrc
12+
if [ "$1" = "--sgx" ] && [ "$PLATFORM" = "linux" ]; then
13+
IWASM_CMD="$CUR_DIR/../../../product-mini/platforms/${PLATFORM}-sgx/enclave-sample/iwasm"
14+
WAMRC_CMD="$CUR_DIR/../../../wamr-compiler/build/wamrc -sgx"
15+
else
16+
IWASM_CMD="$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm"
17+
WAMRC_CMD="$CUR_DIR/../../../wamr-compiler/build/wamrc"
18+
fi
1419

1520
BENCH_NAME_MAX_LEN=20
1621

0 commit comments

Comments
 (0)