Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/push-to-other-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ jobs:
- name: Compile C++ to WASM
run: |
mkdir -p public
emcc lkmc-wasm.cpp -o public/lkmc-wasm.js -O3 -fexceptions -sEXPORT_ES6 -sMODULARIZE -sEXPORTED_FUNCTIONS="['_set_params','_init_simulation','_run_steps','_get_lattice','_get_lattice_size','_get_width','_get_height','_get_step','_get_time','_get_fill','_cleanup_simulation','_force_update_frontend']" -sEXPORTED_RUNTIME_METHODS="['ccall','cwrap', 'HEAP8', 'wasmMemory']"

em++ lkmc-wasm.cpp -o public/lkmc-wasm.js -O3 -std=c++17 -fexceptions -sINITIAL_MEMORY=268435456 -sALLOW_MEMORY_GROWTH=1 -sEXPORT_ES6=1 -sMODULARIZE=1 -sEXPORTED_FUNCTIONS="['_set_params','_set_carbon_species_energy','_get_carbon_species_grid','_update_simulation_params','_init_simulation','_mark_carbon','_unmark_carbon','_finalize_carbon_placement','_run_steps','_get_lattice_data','_get_width','_get_stats_json','_get_stats_json_len','_get_height','_get_lattice','_get_lattice_size','_get_fill','_get_passivated','_get_step','_get_time','_get_wall_time','_play','_pause','_stop','_step_once','_playback_tick','_set_batch_size','_set_stats_interval','_get_stats_interval','_get_playback_state','_get_terminated','_get_cell_coordination','_get_snapshot_count','_get_snapshot_step','_get_snapshot_lattice','_save_state','_get_save_state_len','_load_state','_peek_state_dimensions','_run_batch','_get_batch_json','_cleanup_simulation','_force_update_frontend','_malloc','_free']" -sEXPORTED_RUNTIME_METHODS="['ccall','cwrap','HEAP8','HEAPU8','HEAP32','HEAPF64','wasmMemory']"
- name: Push Build Artifacts to Destination Repo
if: github.ref == 'refs/heads/main'
env:
Expand Down
30 changes: 27 additions & 3 deletions lkmc-wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
* WASM version of C++ port of LKMC_v2_commented_b.py.
*
* * Build:
* emcc lkmc-wasm.cpp -o public/lkmc-wasm.js -O3 -fexceptions -sINITIAL_MEMORY=268435456 -sEXPORT_ES6 -sMODULARIZE -sEXPORTED_FUNCTIONS="['_set_params','_update_simulation_params','_save_state','_get_save_state_len','_load_state','_peek_state_dimensions','_init_simulation','_run_steps','_play','_pause','_stop','_step_once','_playback_tick','_set_batch_size','_set_stats_interval','_get_stats_interval','_get_playback_state','_mark_carbon','_unmark_carbon','_finalize_carbon_placement','_set_carbon_species_energy','_get_carbon_species_grid','_run_batch','_get_batch_json','_get_lattice_data','_get_lattice','_get_lattice_size','_get_width','_get_height','_get_step','_get_wall_time','_get_time','_get_fill','_get_stats_json','_get_stats_json_len','_get_passivated','_get_terminated','_get_cell_coordination','_get_snapshot_count','_get_snapshot_step','_get_snapshot_lattice','_cleanup_simulation','_force_update_frontend','_malloc','_free']" -sEXPORTED_RUNTIME_METHODS="['ccall','cwrap','HEAP8','HEAPU8','HEAP32','HEAPF64','wasmMemory']"
* em++ lkmc-wasm.cpp -o public/lkmc-wasm.js \
-O3 -std=c++17 -fexceptions \
-sINITIAL_MEMORY=268435456 \
-sALLOW_MEMORY_GROWTH=1 \
-sEXPORT_ES6=1 -sMODULARIZE=1 \
-sEXPORTED_FUNCTIONS='["_set_params","_set_carbon_species_energy","_get_carbon_species_grid","_update_simulation_params","_init_simulation","_mark_carbon","_unmark_carbon","_finalize_carbon_placement","_run_steps","_get_lattice_data","_get_width","_get_stats_json","_get_stats_json_len","_get_height","_get_lattice","_get_lattice_size","_get_fill","_get_passivated","_get_step","_get_time","_get_wall_time","_play","_pause","_stop","_step_once","_playback_tick","_set_batch_size","_set_stats_interval","_get_stats_interval","_get_playback_state","_get_terminated","_get_cell_coordination","_get_snapshot_count","_get_snapshot_step","_get_snapshot_lattice","_save_state","_get_save_state_len","_load_state","_peek_state_dimensions","_run_batch","_get_batch_json","_cleanup_simulation","_force_update_frontend","_malloc","_free"]' \
-sEXPORTED_RUNTIME_METHODS='["ccall","cwrap","HEAP8","HEAPU8","HEAP32","HEAPF64","wasmMemory"]' \
-sALLOW_TABLE_GROWTH=1
* Exported WASM stuff:
* _set_params(int Nx, int Ny, double d0, double T, double e0, double e1, double nu_f, double nu_d, double nu_p, double e_pass, double nu_dp, double e_dp, int seed)
* _update_simulation_params(double d0, double T, double nu_f, double nu_d, double nu_p, double e_pass, double e0, double e1, double nu_dp, double e_dp)
Expand Down Expand Up @@ -2343,20 +2350,37 @@ extern "C"
int nx,
int ny,
int steps_per_run,
int base_seed)
int base_seed,
double nu_f,
double nu_d,
double nu_p,
double e_pass,
double nu_dp,
double e_dp)
{
std::ostringstream json;
json << "[";

for (int i = 0; i < num_runs; i++)
{
KMCParams p = wasm_params; // inherit current defaults (carbon energies, etc.)
KMCParams p = wasm_params; // inherit carbon energies, etc.
p.Nx = nx;
p.Ny = ny;
p.d0 = d0_arr[i];
p.T = T_arr[i];
p.e0 = e0_arr[i];
p.e1 = e1_arr[i];
// Previously these came only from wasm_params (last set_params()
// call, i.e. the last time the main Run button was pressed) --
// meaning Batch Run silently ignored the current hop/passivation
// sliders unless you'd just run the main sim with matching
// values. Now explicit, same as set_params/update_params.
p.nu_f = nu_f;
p.nu_d = nu_d;
p.nu_p = nu_p;
p.e_pass = std::max(e_pass, 0.05);
p.nu_dp = nu_dp;
p.e_dp = std::max(e_dp, 0.05);
p.rng_seed = base_seed + i;
p.pcg.seed((uint64_t)p.rng_seed);

Expand Down
Loading