Skip to content

Commit

Permalink
Merge pull request #71 from yomaytk/fs_mark_wasi
Browse files Browse the repository at this point in the history
Fix for executing fs_mark benchmark test for WASI environment.
  • Loading branch information
yomaytk authored Nov 27, 2024
2 parents f95efd5 + cb6e08f commit b9bb72c
Show file tree
Hide file tree
Showing 16 changed files with 1,569 additions and 49 deletions.
4 changes: 2 additions & 2 deletions backend/remill/lib/Arch/AArch64/Arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ bool TryDecodeSTR_H_LDST_IMMPRE(const InstData &data, Instruction &inst) {
// STR <St>, [<Xn|SP>, #<simm>]!
bool TryDecodeSTR_S_LDST_IMMPRE(const InstData &data, Instruction &inst) {
inst.sema_func_arg_type = SemaFuncArgType::Runtime;
AddRegOperand(inst, kActionRead, kRegB, kUseAsValue, data.Rt);
AddRegOperand(inst, kActionRead, kRegS, kUseAsValue, data.Rt);
uint64_t offset = static_cast<uint64_t>(data.imm9.simm9);
AddPreIndexMemOp(inst, kActionWrite, 32, data.Rn, offset);
return true;
Expand All @@ -1554,7 +1554,7 @@ bool TryDecodeSTR_S_LDST_IMMPRE(const InstData &data, Instruction &inst) {
// STR <Dt>, [<Xn|SP>, #<simm>]!
bool TryDecodeSTR_D_LDST_IMMPRE(const InstData &data, Instruction &inst) {
inst.sema_func_arg_type = SemaFuncArgType::Runtime;
AddRegOperand(inst, kActionRead, kRegB, kUseAsValue, data.Rt);
AddRegOperand(inst, kActionRead, kRegD, kUseAsValue, data.Rt);
uint64_t offset = static_cast<uint64_t>(data.imm9.simm9);
AddPreIndexMemOp(inst, kActionWrite, 64, data.Rn, offset);
return true;
Expand Down
18 changes: 11 additions & 7 deletions examples/benchmarks/fs_mark/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@ COBJS= fs_mark.o lib_timing.o

CC ?= gcc
EMCC ?= emcc
WASISDKCC ?= ${WASI_SDK_PATH}/bin/clang
CFLAGS ?= -O3
LDFLAGS ?=
CFLAGS += -Wall -D_FILE_OFFSET_BITS=64

all: fs_mark

fs_mark.o: fs_mark.c fs_mark.h
fs_mark: fs_mark.c lib_timing.c
$(CC) $(CFLAGS) -static -o fs_mark.aarch64 fs_mark.c lib_timing.c $(LDFLAGS)

fs_mark: fs_mark.o lib_timing.o
$(CC) $(CFLAGS) -static -o fs_mark.aarch64 fs_mark.o lib_timing.o $(LDFLAGS)
fs_mark_tmp: wasi_fs_mark.c lib_timing.c
$(CC) $(CFLAGS) -static -o tmp_fs_mark.aarch64 wasi_fs_mark.c lib_timing.c $(LDFLAGS)

fs_mark_wasm: fs_mark.c lib_timing.c
$(EMCC) -O3 -c fs_mark.c -o fs_mark.wasm.o
$(EMCC) -O3 -c lib_timing.c -o lib_timing.wasm.o
$(EMCC) -O3 -static -o fs_mark.html fs_mark.wasm.o lib_timing.wasm.o
fs_mark_emcc: fs_mark.c lib_timing.c
$(EMCC) -O3 -o fs_mark.html fs_mark.wasm.c lib_timing.wasm.c

fs_mark_wasi: fs_mark.c lib_timing.c
$(WASISDKCC) -O3 wasi_fs_mark.c lib_timing.c -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_GETPID \
-lwasi-emulated-process-clocks -lwasi-emulated-getpid -o fs_mark_wasi.wasm

test: fs_mark
./fs_mark -d ${DIR1} -d ${DIR2} -s 51200 -n 4096
Expand Down
Binary file modified examples/benchmarks/fs_mark/fs_mark.aarch64
Binary file not shown.
16 changes: 7 additions & 9 deletions examples/benchmarks/fs_mark/fs_mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,9 @@ void setup_file_name(int file_index, pid_t my_pid)
*/
if ((mkdir(names[file_index].target_dir, 0777) != 0)
&& (errno != EEXIST)) {
// fprintf(stderr, "fs_mark: mkdir %s failed: %s\n",
// names[file_index].target_dir, strerror(errno));
// cleanup_exit();
// printf("mkdir failed??? target_dir:%s, errno: %d\n", names[file_index].target_dir, errno);
fprintf(stderr, "fs_mark: mkdir %s failed: %s\n",
names[file_index].target_dir, strerror(errno));
cleanup_exit();
}

sprintf(names[file_index].write_dir, "%s", names[file_index].target_dir);
Expand Down Expand Up @@ -506,11 +505,10 @@ void setup(pid_t pid)
my_dir = find_dir_name(pid);

if ((mkdir(my_dir, 0777) != 0) && (errno != EEXIST)) {
// fprintf(stderr,
// "fill_dir:mkdir %s failed: %s, errno: %d\n", my_dir, errno,
// strerror(errno));
// cleanup_exit();
// printf("mkdir failed?: my_dir: %s, errno: %d\n", my_dir, errno);
fprintf(stderr,
"fill_dir:mkdir %s failed: %s, errno: %d\n", my_dir, errno,
strerror(errno));
cleanup_exit();
}

return;
Expand Down
Binary file added examples/benchmarks/fs_mark/tmp_fs_mark.aarch64
Binary file not shown.
Loading

0 comments on commit b9bb72c

Please sign in to comment.