Skip to content

Commit

Permalink
remove cur_count forever
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryang00 committed Feb 6, 2024
1 parent 7b7f050 commit 5266f2f
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 76 deletions.
79 changes: 79 additions & 0 deletions artifact/bench_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import pickle
import common_util
from multiprocessing import Pool

cmd = [
"linpack","llama"
]
arg = [
[],["stories15M.bin", "-z", "tokenizer.bin", "-t", "0.0"],
]


pool = Pool(processes=40)
results = []
def run_mvvm():
global results
results1 = []
for i in range(len(cmd)):
for j in range(len(common_util.aot_variant)):
for env in common_util.list_of_arg:
aot = cmd[i] + common_util.aot_variant[j]
results1.append(pool.apply_async(common_util.run_checkpoint, (aot, arg[i], env)))
# print the results
results += [x.get() for x in results1]


def run_criu():
global results
results1 = []

for i in range(len(cmd)):
aot = cmd[i]
results1.append(
pool.apply_async(
common_util.run_criu, (aot, "linpack", arg[i], "OMP_NUM_THREADS=1")
)
)
# print the results
results += [x.get() for x in results1]


def run_qemu_x86_64():
global results
results1 = []

for i in range(len(cmd)):
aot = cmd[i]
results1.append(
pool.apply_async(
common_util.run_qemu_x86_64, (aot, "linpack", arg[i], "OMP_NUM_THREADS=1")
)
)
# print the results
results += [x.get() for x in results1]


run_criu()
run_qemu_x86_64()

# print the results

run_qemu_x86_64()
run_criu()
with open("bench_migration_results.pickle", "wb") as f:
pickle.dump(results, f)
for exec, output in results:
print(exec)
lines = output.split("\n")
for line in lines:
if (
line.__contains__("Execution time:")
or line.__contains__("real")
or line.__contains__("user")
):
print(line)

# read the results
with open("bench_migration_results.pickle", "rb") as f:
results = pickle.load(f)
40 changes: 40 additions & 0 deletions artifact/common_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,46 @@ def build():
return


def run_checkpoint(aot_file: str, arg: list[str], env: str) -> tuple[str, str]:
cmd = f"LOGV=5 ./MVVM_checkpoint -t ../build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env}"
print(cmd)
cmd = cmd.split()
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
output = result.stdout.decode("utf-8")
except:
output = result.stdout
exec = " ".join([env] + [aot_file] + arg)
# print(exec)
# print(output)
return (exec, output)

def run_restore(aot_file: str, arg: list[str], env: str) -> tuple[str, str]:
cmd = f"LOGV=5 ./MVVM_checkpoint -t ../build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env}"
print(cmd)
cmd = cmd.split()
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
output = result.stdout.decode("utf-8")
except:
output = result.stdout
exec = " ".join([env] + [aot_file] + arg)
return (exec, output)

def run_criu_checkpoint(aot_file: str, arg: list[str], env: str) -> tuple[str, str]:
cmd = f"LOGV=5 ./MVVM_checkpoint -t ../build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env}"
print(cmd)
cmd = cmd.split()
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
output = result.stdout.decode("utf-8")
except:
output = result.stdout
exec = " ".join([env] + [aot_file] + arg)
# print(exec)
# print(output)
return (exec, output)

def run(aot_file: str, arg: list[str], env: str) -> tuple[str, str]:
cmd = f"LOGV=5 ./MVVM_checkpoint -t ../build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env}"
print(cmd)
Expand Down
5 changes: 2 additions & 3 deletions include/wamr.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class WAMRInstance {
std::condition_variable sync_op_cv;
std::map<ssize_t, ssize_t> tid_map;
std::map<ssize_t, ssize_t> child_tid_map;
std::map<ssize_t, size_t> tid_start_arg_map;
std::map<ssize_t, std::pair<int,int>> tid_start_arg_map;
uint32 id{};
size_t cur_thread;
std::chrono::time_point<std::chrono::high_resolution_clock> time;
Expand All @@ -86,7 +86,6 @@ class WAMRInstance {
bool replace_mfence_with_nop();
bool replace_nop_with_int3();
void replay_sync_ops(bool, wasm_exec_env_t);
void register_tid_map();
WASMFunction *get_func();
void set_func(WASMFunction *);
#if WASM_ENABLE_AOT != 0
Expand All @@ -101,7 +100,7 @@ class WAMRInstance {
void set_wasi_args(const std::vector<std::string> &dir_list, const std::vector<std::string> &map_dir_list,
const std::vector<std::string> &env_list, const std::vector<std::string> &arg_list,
const std::vector<std::string> &addr_list, const std::vector<std::string> &ns_lookup_pool);
void spawn_child(WASMExecEnv *main_env);
void spawn_child(WASMExecEnv *main_env, bool);

int invoke_main();
void invoke_init_c();
Expand Down
2 changes: 1 addition & 1 deletion include/wamr_exec_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct WAMRExecEnv { // multiple
/** We need to put Module Inst at the top. */
WAMRModuleInstance module_inst{};
/* The thread id of wasm interpreter for current thread. */
uint32 cur_count{};
uint64 cur_count{};
uint32 flags;

/* Auxiliary stack boundary */
Expand Down
5 changes: 3 additions & 2 deletions include/wamr_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum sync_op {
};

struct sync_op_t {
uint32 tid;
uint64 tid;
uint32 ref;
enum sync_op sync_op;
};
Expand All @@ -42,7 +42,7 @@ void set_tcp();
int get_sock_fd(int);
void insert_sync_op(wasm_exec_env_t exec_env, const uint32 *mutex, enum sync_op locking);
void restart_execution(uint32 targs);
void insert_tid_start_arg(ssize_t, size_t);
void insert_tid_start_arg(ssize_t, size_t, size_t);
void change_thread_id_to_child(ssize_t, ssize_t);
void insert_parent_child(ssize_t, ssize_t);
extern int pthread_create_wrapper(wasm_exec_env_t exec_env, uint32 *thread, const void *attr, uint32 elem_index,
Expand All @@ -59,6 +59,7 @@ void insert_fd(int, const char *, int, int, enum fd_op op);
void remove_fd(int);
void rename_fd(int, char const *, int, char const *);
bool is_atomic_checkpointable();
void wamr_handle_map(ssize_t old_tid, ssize_t new_tid);
void lightweight_checkpoint(WASMExecEnv *);
void lightweight_uncheckpoint(WASMExecEnv *);
void wamr_wait(wasm_exec_env_t);
Expand Down
2 changes: 1 addition & 1 deletion include/wamr_wasi_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct WAMRWASIContext {
std::vector<std::string> env_list;
std::vector<std::string> addr_pool;
std::vector<std::string> ns_lookup_list;
std::map<int, int> tid_start_arg_map;
std::map<int, std::pair<int, int>> tid_start_arg_map;
std::map<int, int> child_tid_map;
uint32_t exit_code;

Expand Down
Loading

0 comments on commit 5266f2f

Please sign in to comment.