NFT-Marker-Creator icon indicating copy to clipboard operation
NFT-Marker-Creator copied to clipboard

Testing NFT-Marker-Creator with SIMD instructions

Open kalwalt opened this issue 5 years ago • 15 comments

According to this article is possible to compile and build WASM code with SIMD instructions. This could be improve the performances for the NFT-Marker-Creator and maybe require less time to produce a NFT Marker, at least for who want to try this feature. I would try this but not sure if i have the time to do now....

kalwalt avatar Feb 05 '20 18:02 kalwalt

@kalwalt interesting, I will look into it. Sorry for taking a long time to answer :disappointed:

Carnaux avatar Feb 11 '20 20:02 Carnaux

@Carnaux don't worry ! it's also a reminder for me or a suggestion for other. I would like to try when i have a bit of time but this need also to compile a WASM version of the lib as stated in the other issue #34 I think that we can have a sensible difference for the time build of the NFT markers with WASM + SIMD.

kalwalt avatar Feb 11 '20 20:02 kalwalt

I'm testing the SIMD + WASM in this branch for now i'm getting this error:

stderr: shared:ERROR: undefined exported function: "_createImageSet"

if someone want to test remember to use latest-upstream distribution of emscripten.

kalwalt avatar Feb 12 '20 18:02 kalwalt

I don't receive this error: stderr: shared:ERROR: undefined exported function: "_createImageSet" when i build with the upstream emscripten backend without the SIMD directive. So i suppose is a specific issue with this last. We will see how to solve. Tested with latest upstream emscripten:

/home/walter/emsdk/upstream/emscripten/emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.7
clang version 11.0.0 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project fc19465965a74cffa41e385f3cfe9bfca6a7950d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/walter/emsdk/upstream/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
shared:INFO: (Emscripten: Running sanity checks)

kalwalt avatar Feb 13 '20 21:02 kalwalt

With SIMD the code may be exporting the "_createImageSet" function with a different name or, what I think is more possible, exporting without the underscore symbol. To check that you can console.log the Module variable and check its available methods.

Carnaux avatar Feb 13 '20 21:02 Carnaux

It could be, maybe i can do a research on the emscripten docs.

To check that you can console.log the Module variable and check its available methods.

yes but i think i can not acces if the project fails to build.

kalwalt avatar Feb 13 '20 21:02 kalwalt

Strange, because the use of _createImageSet is only in the app.js

Carnaux avatar Feb 13 '20 21:02 Carnaux

HI, I have been testing and works fine. But it does not improve the master performance. I don't understand well why you want improve JS part of NFT in case of generating marker (on detecting process make sense for me), server as webservice is not enough to do this ? Maybe I am loosing something ...

itamayo avatar Feb 17 '20 09:02 itamayo

@itamayo you should compare the .min version and the .wasm version. Improving has sense to me just for testing. Anyway is an experimental feature you need to enable it with a flag in the browser, so i think it is more difficult to release a jsartoolkit5 version with SIMD than a NFT-Marker-Creator with SIMD.

kalwalt avatar Feb 17 '20 09:02 kalwalt

it is more difficult to release a jsartoolkit5 version with SIMD than a NFT-Marker-Creator with SIMD.

Good point .. =D

Wow ! Improvement with flag on is good enough, 2 time faster !! It should help on detecting version ... What do you think about testing SIMD on jsArtoolkit ? How hard would be ? Do you think It would help ?

itamayo avatar Feb 17 '20 11:02 itamayo

Wow ! Improvement with flag on is good enough, 2 time faster !! It should help on detecting version ... What do you think about testing SIMD on jsArtoolkit ? How hard would be ? Do you think It would help ?

Which flag? We don't build the libs with SIMD yet. Explain this, please. :smile: At least me, maybe @Carnaux did it?

kalwalt avatar Feb 17 '20 11:02 kalwalt

A ok, .min is not wasm version ... So wasm is 2 time faster than before ?

itamayo avatar Feb 17 '20 11:02 itamayo

A ok, .min is not wasm version ... So wasm is 2 time faster than before ?

yes are different libs .min the minified lib use asm.js .wasm use Webassembly and should be always faster. I don't know if it is 2 time faster, need to do a good test, but anyway in our opinion is faster. SIMD must be tested only in the webassembly version of the lib because on asm. has no sense. (in the Emscripten docs is discouraged) As i said i would start with this project because is simpler, only few functions to look at. and less problematic. But we need to solve the initial error as said in this comment https://github.com/Carnaux/NFT-Marker-Creator/issues/33#issuecomment-585338936

kalwalt avatar Feb 17 '20 11:02 kalwalt

OK, sorry about my confusion ... I gonna test your branch, lets see what I can do, if can do xD

itamayo avatar Feb 17 '20 11:02 itamayo

I test compilation with SIMD enable and there is not appreciable effect. 960x720 image 72 DPI ~43 seconds. I don't see any way to improve rather than modification of Artoolkit source to run with threads.

This loop https://github.com/artoolkit/ARToolKit5/blob/master/lib/SRC/AR2/imageSet.c#L73 take more than half time of the process

itamayo avatar Feb 17 '20 14:02 itamayo