1f4082a4cSAlexandra<!-- 2f4082a4cSAlexandra****************************************************************************** 3f4082a4cSAlexandra* 4f4082a4cSAlexandra* Licensed under the Apache License, Version 2.0 (the "License"); 5f4082a4cSAlexandra* you may not use this file except in compliance with the License. 6f4082a4cSAlexandra* You may obtain a copy of the License at 7f4082a4cSAlexandra* 8f4082a4cSAlexandra* http://www.apache.org/licenses/LICENSE-2.0 9f4082a4cSAlexandra* 10f4082a4cSAlexandra* Unless required by applicable law or agreed to in writing, software 11f4082a4cSAlexandra* distributed under the License is distributed on an "AS IS" BASIS, 12f4082a4cSAlexandra* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f4082a4cSAlexandra* See the License for the specific language governing permissions and 14f4082a4cSAlexandra* limitations under the License. 15f4082a4cSAlexandra*******************************************************************************/--> 16f4082a4cSAlexandra 17f4082a4cSAlexandra# WASM Support 18f4082a4cSAlexandra 19a71747cdSAlexandraoneTBB extends its capabilities by offering robust support for ``WASM``. 20a71747cdSAlexandra 21f4082a4cSAlexandra``WASM`` stands for WebAssembly, a low-level binary format for executing code in web browsers. 22a71747cdSAlexandraIt is designed to be a portable target for compilers and efficient to parse and execute. 23f4082a4cSAlexandra 24a71747cdSAlexandraUsing oneTBB with WASM, you can take full advantage of parallelism and concurrency while working on web-based applications, interactive websites, and a variety of other WASM-compatible platforms. 25f4082a4cSAlexandra 26a71747cdSAlexandraoneTBB offers WASM support through the integration with [Emscripten*](https://emscripten.org/docs/introducing_emscripten/index.html), a powerful toolchain for compiling C and C++ code into WASM-compatible runtimes. 27f4082a4cSAlexandra 28a71747cdSAlexandra## Build 29a71747cdSAlexandra 30a71747cdSAlexandra**Prerequisites:** Download and install Emscripten*. See the [instructions](https://emscripten.org/docs/getting_started/downloads.html). 31a71747cdSAlexandra 32a71747cdSAlexandraTo build the system, run: 33a71747cdSAlexandra 34a71747cdSAlexandra``` 35a71747cdSAlexandramkdir build && cd build 36a71747cdSAlexandraemcmake cmake .. -DCMAKE_CXX_COMPILER=em++ -DCMAKE_C_COMPILER=emcc -DTBB_STRICT=OFF -DCMAKE_CXX_FLAGS=-Wno-unused-command-line-argument -DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=ON -DBUILD_SHARED_LIBS=ON -DTBB_EXAMPLES=ON -DTBB_TEST=ON 37*fabaaa65SJhaShweta1``` 38*fabaaa65SJhaShweta1To compile oneTBB without ``pthreads``, set the flag ``-DEMSCRIPTEN_WITHOUT_PTHREAD=true`` in the command above. By default, oneTBB uses the ``pthreads``. 39*fabaaa65SJhaShweta1``` 40a71747cdSAlexandracmake --build . <options> 41a71747cdSAlexandracmake --install . <options> 42a71747cdSAlexandra``` 43a71747cdSAlexandraWhere: 44a71747cdSAlexandra 45a71747cdSAlexandra* ``emcmake`` - a tool that sets up the environment for Emscripten*. 46a71747cdSAlexandra* ``-DCMAKE_CXX_COMPILER=em++`` - specifies the C++ compiler as Emscripten* C++ compiler. 47a71747cdSAlexandra* ``-DCMAKE_C_COMPILER=emcc`` - specifies the C compiler as Emscripten* C compiler. 48f4082a4cSAlexandra 49f4082a4cSAlexandra 50a71747cdSAlexandra> **_NOTE:_** See [CMake documentation](https://github.com/oneapi-src/oneTBB/blob/master/cmake/README.md) to learn about other options. 51a71747cdSAlexandra 52a71747cdSAlexandra 53a71747cdSAlexandra## Run Test 54a71747cdSAlexandra 55a71747cdSAlexandraTo run tests, use: 56a71747cdSAlexandra 57a71747cdSAlexandra``` 58a71747cdSAlexandractest 59a71747cdSAlexandra``` 60f4082a4cSAlexandra 61