Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emscripten build #1040

Merged
merged 2 commits into from
Sep 15, 2022
Merged

emscripten build #1040

merged 2 commits into from
Sep 15, 2022

Conversation

jedbrown
Copy link
Member

I can build and run the pure libceed examples, which means we could embed them in a static web page that would run simulations in the user's browser.

This now builds cleanly:

$ emmake make STATIC=1 OPT=-O build/ex2-surface.wasm
[...]
$ wasmer run build/ex2-surface.wasm -- -s 32767
[...]
Exact mesh surface area    :  6
Computed mesh surface area :  5.9548265118955
Surface area error         : -0.04517348810445

Increasing the size causes calloc to fail, likely to do some default memory limits that I haven't worked out yet.

Emscripten docs: https://emscripten.org/docs/compiling/Building-Projects.html#building-projects

interface/ceed-qfunction.c Outdated Show resolved Hide resolved
@jeremylt
Copy link
Member

jeremylt commented Sep 6, 2022

Do we want to include this in the release? The above suggestion would be a ~15 minute commit that I could put together.

@jedbrown
Copy link
Member Author

jedbrown commented Sep 6, 2022

I think it would be wonderful if we can, and then add a cursory emscripten build (just the base library) to CI.

emcc looks for the output suffix .wasm when linking executables.

This now builds cleanly:

$ emmake make STATIC=1 OPT=-O build/ex2-surface.wasm
[...]
$ wasmer run build/ex2-surface.wasm -- -s 32767
[...]
Exact mesh surface area    :  6
Computed mesh surface area :  5.9548265118955
Surface area error         : -0.04517348810445

Increasing the size causes calloc to fail, likely to do some default
memory limits that I haven't worked out yet.

Emscripten docs:

https://emscripten.org/docs/compiling/Building-Projects.html#building-projects
@jedbrown
Copy link
Member Author

I don't think it was intended to close this PR, though this PR should be rebased (by someone, maybe me).

@jedbrown jedbrown reopened this Sep 12, 2022
@jeremylt
Copy link
Member

I can do a quick rebase

@jeremylt
Copy link
Member

$ emmake make STATIC=1 OPT=-O build/ex2-surface.wasm -j
make: make STATIC=1 OPT=-O build/ex2-surface.wasm -j
make: 'lib' with optional backends: 
          CC build/interface/ceed-basis.o
          CC build/interface/ceed.o
          CC build/interface/ceed-elemrestriction.o
          CC build/interface/ceed-fortran.o
          CC build/interface/ceed-jit-source-root-default.o
          CC build/interface/ceed-jit-tools.o
          CC build/interface/ceed-operator.o
          CC build/interface/ceed-preconditioning.o
          CC build/interface/ceed-qfunction.o
          CC build/interface/ceed-qfunctioncontext.o
          CC build/interface/ceed-qfunction-register.o
          CC build/interface/ceed-register.o
          CC build/interface/ceed-tensor.o
          CC build/interface/ceed-types.o
          CC build/interface/ceed-vector.o
          CC build/gallery/identity/ceed-identity.o
          CC build/gallery/mass/ceed-mass1dbuild.o
          CC build/gallery/mass/ceed-mass2dbuild.o
          CC build/gallery/mass/ceed-mass3dbuild.o
          CC build/gallery/mass/ceed-massapply.o
          CC build/gallery/mass-vector/ceed-vectormassapply.o
          CC build/gallery/poisson/ceed-poisson1dapply.o
          CC build/gallery/poisson/ceed-poisson1dbuild.o
          CC build/gallery/poisson/ceed-poisson2dapply.o
          CC build/gallery/poisson/ceed-poisson2dbuild.o
          CC build/gallery/poisson/ceed-poisson3dapply.o
          CC build/gallery/poisson/ceed-poisson3dbuild.o
          CC build/gallery/poisson-vector/ceed-vectorpoisson1dapply.o
          CC build/gallery/poisson-vector/ceed-vectorpoisson2dapply.o
          CC build/gallery/poisson-vector/ceed-vectorpoisson3dapply.o
          CC build/gallery/scale/ceed-scale.o
          CC build/backends/ref/ceed-ref-basis.o
          CC build/backends/ref/ceed-ref-operator.o
          CC build/backends/ref/ceed-ref-qfunction.o
          CC build/backends/ref/ceed-ref-qfunctioncontext.o
          CC build/backends/ref/ceed-ref-restriction.o
          CC build/backends/ref/ceed-ref-tensor.o
          CC build/backends/ref/ceed-ref-vector.o
          CC build/backends/ref/ceed-ref.o
          CC build/backends/blocked/ceed-blocked-operator.o
          CC build/backends/blocked/ceed-blocked.o
          CC build/backends/opt/ceed-opt-blocked.o
          CC build/backends/opt/ceed-opt-operator.o
          CC build/backends/opt/ceed-opt-serial.o
          CC build/backends/opt/ceed-opt-tensor.o
          CC build/backends/ceed-backend-weak.o
          CC build/gallery/ceed-gallery-weak.o
          AR lib/libceed.a
      LINK.c build/ex2-surface.wasm
$ wasmer run build/ex2-surface.wasm -- -s 32767
Selected options: [command line option] : <current value>
  Ceed specification [-c] : /cpu/self
  Mesh dimension     [-d] : 3
  Mesh degree        [-m] : 4
  Solution degree    [-p] : 4
  Num. 1D quadr. pts [-q] : 6
  Approx. # unknowns [-s] : 32767
  QFunction source   [-g] : header

Mesh size: nx = 8, ny = 8, nz = 4
Number of mesh nodes     : 18513
Number of solution nodes : 18513
 done.
Exact mesh surface area    :  6
Computed mesh surface area :  5.9548265118955
Surface area error         : -0.04517348810445

@jeremylt
Copy link
Member

Did you want to add this to the docs here or in a follow-up?

@jedbrown
Copy link
Member Author

Thanks. I think this can be a sleeper feature until we figure out the size limit and get it in CI, at which point we can announce it.

@jedbrown jedbrown merged commit 417419b into main Sep 15, 2022
@jedbrown jedbrown deleted the jed/emscripten-build branch September 15, 2022 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants