GithubHelp home page GithubHelp logo

Comments (10)

pca006132 avatar pca006132 commented on July 20, 2024 2

OK I have successfully compiling and running the code with emscripten. You have to:

  1. Change all the .cu files to .cpp. (actually not sure if this is needed, but I need to do this to use clang++ to build the project instead of using nvcc)
  2. Comment out modules that uses libraries that you don't plan to deal with now, e.g. assimp. I think we should be able to use this, but I am too lazy to deal with it now.
  3. Set include path to thrust and glm explicitly in the CMakeLists.txt, otherwise emscripten won't be able to find them.
  4. Specify emscripten toolchain file: CMAKE_TOOLCHAIN_FILE=path/to/emscripten/emscripten/version/cmake/Modules/Platform/Emscripten.cmake (from https://github.com/adevaykin/minimal-cmake-emscripten-project)
  5. Build with MANIFOLD_USE_CPP=on.

You may want to build with -DCMAKE_CXX_FLAGS="-s ALLOW_MEMORY_GROWTH=1". I tried building without this argument and the perfTest failed with out of memory error. Not sure if this is the appropriate way to do this because em++ is complaining about linker setting ignored during compilation, but at the end it seems working.

from manifold.

elalish avatar elalish commented on July 20, 2024 1

I certainly don't, but having an emscripten build would be awesome! Feel free to open a draft PR with what you've tried so we can follow along.

from manifold.

pca006132 avatar pca006132 commented on July 20, 2024 1

Yes this can be integrated into the CMake script and test it on GitHub Actions CI, but this requires some modifications:

  1. Change all .cu files to .cpp. I think we can still get nvcc to treat them as CUDA source files by set_source_files_properties(${CUDA_SOURCES} PROPERTIES LANGUAGE CUDA), haven't yet tried this though.
  2. We may need to put the dependencies as git submodules in the third_party directory, or ask users to specify the path to these dependencies manually via CMake variables when compiling with emscripten. I tried using find_package for packages like glm and thrust but this does not work, I am not familiar with CMake and C++ so not sure if I am doing this correctly.

Also, it will be nice if we can specify the gtest dependency as git a submodule rather than using CMake to download it. I can package this with NixOS for reproducible builds, but it forbids network connection for pure builds so CMake will not be able to download gtest from the web.

I just tried building assimp with emscripten and it seems that it builds fine out of the box for v5.2.3. Will try to link against it and do some tests.

from manifold.

pca006132 avatar pca006132 commented on July 20, 2024

Wondering if this is possible with nvcc. Probably easier after switching to C++20 parallel algorithms?

from manifold.

thmax avatar thmax commented on July 20, 2024

I think it's possible, this repo https://github.com/jstepien/boids seems to achieve it but i didn't try to compile it.
It will be easier indeed with c++ 20

from manifold.

pca006132 avatar pca006132 commented on July 20, 2024

It seems to me that the make file is compiling the cpu simulation to llvm IR using clang, and then use emscripten to compile the LLVM IR to JavaScript. I don't think nvcc can emit LLVM IR (at least I don't see an option for this).

from manifold.

elalish avatar elalish commented on July 20, 2024

You can build this library without nvcc, as long as you're not targeting the CUDA backend. Thrust is just a header-only C++ lib. That may be a path forward.

What I'd really love to see is emscripten taking C++20 parallel algorithms and converting them to GPU-accelerated WASM (WebGPU?). I would imagine someone somewhere is thinking about that, but I have no idea if/when it might ship.

from manifold.

pca006132 avatar pca006132 commented on July 20, 2024

I've tried using the OpenMP backend and CUDA backend for some tests, it seems that CUDA is quite fast for some larger meshes comparing to OpenMP (which is expected). Wondering if GPU acceleration will be dropped if the goal is to switch to c++ 20 parallel algorithms later.

from manifold.

elalish avatar elalish commented on July 20, 2024

Yes, GPU parallelization is definitely a goal of this library, and I should really be saying C++17, not C++20. std::execution::par targets GPUs, and eventually more of them than CUDA.

from manifold.

elalish avatar elalish commented on July 20, 2024

That's awesome! Fantastic work. It would be great to integrate that into our CMake scripts somehow, maybe even get it building/testing on our Github Actions CI?

from manifold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.