Coder Social home page Coder Social logo

coremark-wasm-android's Introduction

CoreMark v1 on Android

This repository provides a demo Android application that creates a WASM Micro Runtime (WAMR) instance and uses it to run CoreMark v1.

How it works

A copy of WAMR is checked in to app/src/main/cpp/third_party. It is statically linked into a native library that exports a single entry point. This entry point takes a byte array representing the WASM image to run and currently returns nothing. See app/src/main/cpp/native-lib.cpp.

The native library implementation creates a WAMR runtime using wamr_runtime_load and wamr_runtime_instantiate. Details can be found in the Embedding WAMR page in the WAMR docs.

The CoreMark v1 WASM image is loaded from raw Android resources on the JVM side and passed to WAMR through the JNI bridge (see app/src/main/java/com/example/myapplication/MainActivity.kt). The _start symbol from this image is invoked from inside the native library, though this could easily be exposed through JNI.

Input/output

Standard input/output is handled by the WAMR libc WASI implementation (WAMR_BUILD_LIBC_WASI in CMakeLists.txt). CoreMark writes to standard output, flows through the libc WASI implementation to a custom vnsprintf implementation provided by the JNI native library (see WAMR_BH_VPRINTF in CMakeLists.txt). This version of vnsprintf will produce Android logcat logs via __android_log_write.

Log messages generated by the WAMR runtime itself are similarly routed to logcat.

Standard input is not handled yet, but could be similarly routed through the libc WASI interface.

Limitations

Hardware bounds checking

I had to disable hardware bounds checking in WAMR:

// wasm-micro-runtime/core/shared/platform/linux/platform_internal.h

#undef OS_ENABLE_HW_BOUND_CHECK

It causes crashes in touch_pages somewhere in pthreads, I am still investigating.

Supported platforms

I have tested this only on the Android x86 emulator so far. More platforms to come.

Static linking

The demo is currently statically linked against WAMR, but there should be no impediment to using a WAMR implementation in a shared library.

coremark-wasm-android's People

Contributors

sjamesr avatar

Watchers

 avatar

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.