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

Could this work my needs? Some questions on SIMD, AOT... #1191

Closed
warvstar opened this issue Jun 8, 2020 · 5 comments
Closed

Could this work my needs? Some questions on SIMD, AOT... #1191

warvstar opened this issue Jun 8, 2020 · 5 comments
Labels
discussion Welcome discussion! feature request Suggest an idea on this project

Comments

@warvstar
Copy link

warvstar commented Jun 8, 2020

Hi! Currently I'm working on a data orientated game engine that is programmed via Javascript and the kernels are SPIRV(glsl), much like how Taichi uses python and itself(Taichi).

Now the reason I'm here is because I've just found out that this project is already doing most of the things I would need for my backend. However before switching over to Taichi I'd like to ask some questions I haven't found answered yet.

I need something to run on Windows, Mac, Linux, Android, iOS and the web. I'm pretty sure the first three can be accomplished now, I imagine Android is probably pretty easy too. I should have no problem making this run in the browser as I have tons of experience with that.

My main concern is iOS. Currently with my own system I JIT everything during development and then for release I compile AOT and that solves iOS for my needs currently. I haven't looked at the codebase here much yet, but does Taichi have a way to AOT compile kernels or modules? How much work do you think would be involved?

Also, another reason I'd like to see AOT compilation is to keep the binary size of the release program down.

My other question is about SIMD/Vectorization on the CPU. With my current system I compile SPIR-V to ISPC at release, and that gets me vectorization. Anyway, I noticed Taichi had vectorization at one time but then lost it? Has it been added back in? Can it compete with ISPC generated code?

Would this project not benefit from having a SPIR-V backend?

Also, as much as I like python, would anyone be interested in an optional JavaScript front end? I ask because if porting to the web, python is another dependency that could be removed if using JavaScript instead.

By the way, this is an awesome project! Thanks for all the work put into Taichi!

@warvstar warvstar added the feature request Suggest an idea on this project label Jun 8, 2020
@warvstar warvstar changed the title Could this work my needs? Some questions Could this work my needs? Some questions on SIMD, AOT... Jun 8, 2020
@xumingkuan
Copy link
Contributor

Thank you so much for proposing this!

Some quick answers:

Does Taichi have a way to AOT compile kernels or modules?

Not yet, because Taichi is embedded in Python now.

I noticed Taichi had vectorization at one time but then lost it? Has it been added back in?

Yes, Taichi had vectorization at one time and it ran pretty fast. Because we added bunches of features and did aggressive refactoring, Taichi lost vectorization. Vectorization is a great feature and can make Taichi run much faster on CPUs, so it would be of great help if it's added back. However, as #677 addressed, it's unlikely to achieve in v0.7 because of the workload.

@xumingkuan xumingkuan added the discussion Welcome discussion! label Jun 8, 2020
@yuanming-hu
Copy link
Member

Thanks for the questions.

I haven't looked at the codebase here much yet, but does Taichi have a way to AOT compile kernels or modules? How much work do you think would be involved?

Our existing workflow is simply dumping the generated Metal kernels, and write an iOS app to launch these kernels. However we plan to switch to a runtime system so that you can ship with a libtaichi_core.dylib with some IR for JITing. I don't that will be done very soon.

My other question is about SIMD/Vectorization on the CPU. With my current system I compile SPIR-V to ISPC at release, and that gets me vectorization. Anyway, I noticed Taichi had vectorization at one time but then lost it? Has it been added back in? Can it compete with ISPC generated code?

Yeah we used to have vectorization for the old C++ backend, but after we switch to LLVM vectorization hasn't been implemented for the new backend.

Would this project not benefit from having a SPIR-V backend?

Yes, SPIR-V would be really helpful, but the development hasn't started.

Also, as much as I like python, would anyone be interested in an optional JavaScript front end? I ask because if porting to the web, python is another dependency that could be removed if using JavaScript instead.

We plan to add JS/WASM backends, but we haven't started the development: #394

@cloudhan
Copy link

This seems to be interesting.

Regards with ISPC, it is extremely performant based on my experience. It can produce object file and then link with other obj to make libraries or executables, this makes it suitable for gradually accelerate existing code. IMO, to be as flexible as ISPC is, taichi need to be able generate kernel code (compiled or not) without the runtime at all, and let the programmer to manage memory and kernel launch.

@archibate
Copy link
Collaborator

archibate commented Jul 27, 2020

Also, as much as I like python, would anyone be interested in an optional JavaScript front end? I ask because if porting to the web, python is another dependency that could be removed if using JavaScript instead.

We plan to add JS/WASM backends, but we haven't started the development: #394

FYI now the C backend is almost complete #1332, and we are able to export the result C code now. We will have a JS backend once we translate the generated C code into JS via Emscripten. But note that this is simply running pure JS running on CPU, no WebGL acceleration, so no much performance will be expected yet.

Yes, currently the Taichi compiler is highly tied with runtime, therefore cross-compile could be hard. For example, the OpenGL backend assumes all extensions on compiler-side to be available on runtime-side.

@bobcao3
Copy link
Collaborator

bobcao3 commented Dec 13, 2021

Metal AOT module is up and running rn, closing the issue

@bobcao3 bobcao3 closed this as completed Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Welcome discussion! feature request Suggest an idea on this project
Projects
None yet
Development

No branches or pull requests

6 participants