I am new to emscripten, but with some reading and testing, I was able to compile my Monte Carlo photon transport code (
http://mcx.space) to wasm.
here is my project
to try the compilation, you can use the simple commands below:
this compiles my software and generate the output in src/webmmc folder. However, this only works for single-threaded computation. When I changed this line (#108 in mmc/common/Makefile_common.mk)
from "web: release" to "web: omp" to enable multithreading via openmp, and recompile, emcc gave me the following warning at the linking stage
emcc -fopenmp -o bin/mmc built/posix_randr.o built/simpmesh.o built/tettracing.o built/mcx_utils.o built/tictoc.o built/mmc.o built/mmc_host.o built/cjson/cJSON.o -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -s FORCE_FILESYSTEM=1 -o webmmc/webmmc.html
warning: unresolved symbol: __atomic_compare_exchange
warning: unresolved symbol: __atomic_load
warning: unresolved symbol: __kmpc_barrier
warning: unresolved symbol: __kmpc_critical
warning: unresolved symbol: __kmpc_end_critical
warning: unresolved symbol: __kmpc_end_reduce
warning: unresolved symbol: __kmpc_for_static_fini
warning: unresolved symbol: __kmpc_for_static_init_4u
warning: unresolved symbol: __kmpc_fork_call
warning: unresolved symbol: __kmpc_global_thread_num
warning: unresolved symbol: __kmpc_reduce
warning: unresolved symbol: omp_get_thread_num
warning: unresolved symbol: omp_set_num_threads
and generated binary gave me an error in the browser.
Also, if I tried to enable SSE in my code by replacing the above mentioned line#108 in the Makefile_common.mk to "web: ssemath", I got the following error
In an even more ambitious attempt, I would be thrilled if I can port my OpenCL version of the code (
https://github.com/fangq/mcxcl) to the web. I am wondering if there is any experimental support for OpenCL? or if there is a roadmap for that?