Difficulty in porting a high performance Monte Carlo simulator - openmp and sse support

248 views
Skip to first unread message

Qianqian Fang

unread,
Aug 28, 2018, 11:18:11 AM8/28/18
to emscripten-discuss
hi everyone, 

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:

cd mmc/src
make web

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

.../emsdk/emscripten/1.38.11/system/include/SSE/emmintrin.h:49:2: error: "SSE2 instruction set not enabled"
#error "SSE2 instruction set not enabled"

I am wondering if someone has experience enabling OpenMP or SSE support with emscripten? 

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?

thank you very much

Qianqian

Alon Zakai

unread,
Sep 4, 2018, 5:07:04 PM9/4/18
to emscripten-discuss
In general, there is some SIMD support for asm.js, but very partial - browsers have shifted to focus on wasm instead. Wasm SIMD is making fast progress, but not testable yet.

OpenCL is not currently possible. There is no current work on a "WebCL" API, however, compute shaders in WebGL2 or WebGPU may make it possible to implement - too early to tell though, I think.


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages