Calling RenderScript from C / JNI

RonTLV

I'm looking to replace the C atan2 function with something more efficient. RenderScript does offer atan2, including versions that take vectors.

The examples I found, demonstrates calling RenderScript from Java. Is it possible to call RS from C code ? an example would be great.

Thanks

Larry Schiefer

It used to be possible, though RS support in the NDK has been dropped for some time now. It may still be possible, but even the NDK samples no longer include RS samples. Starting with Android 7 you could try to use "Single Source RenderScript", described here, which is supposed to be possible from C/C++ code.

The efficiency gains you may see using RS are due to a few possible reasons (which are very platform dependent):

  1. RS will parallelize operations over your data set. In some cases the function you are calling (such as atan2) may parallelize the operation, if possible.
  2. Your RS code may be executed on a co-processor (such as a GPU or DSP).
  3. The RS provided intrinsics and library functions are highly optimized for the platform. Using atan2 as an example again, it may be possible that the function is more optimized in the RS core than the standard C library as it could be using a co-processor or it could be using architecture specific optimized implementation (assembly).

All of that being said, your code can take an I/O hit when moving data between RS space (Allocation) back to the non-RS code.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling dll implemented JNI from C++

From Dev

Calling C system calls from JNI

From Dev

JNI calling Java from C++ with multiple threads

From Dev

JNI: Calling a java method from C periodically is not working

From Dev

Java JNI NullPointerException after calling method from C with valid pointers

From Dev

Error while calling C# from java using jni4net from 64 bit Os

From Dev

androidx renderscript crash "Error loading RS jni library: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad"

From Dev

Calling a static void Java method from JNI

From Java

Calling a DLL from an Applet via JNI

From Dev

Calling java function from c++ using jni: Failed to find static method id

From Dev

Calling JNI C function in another source file

From Dev

JNI C++ UnsatisfiedLinkError When Calling Method

From Java

JNI: From C code to Java and JNI

From Dev

Data type conversion when (JNI) calling a function from cpp lib

From Dev

Calling Java Methods from JNI results in program crash

From Java

Calling into a saved java object via JNI from a different thread

From Java

JNI calling JVM functions/events from native code?

From Dev

Calling a Java Method from the native code using jni

From Dev

JNI vs JNA, calling Java from Fortran95

From Dev

Calling Swift from C

From Dev

calling system() from c

From Dev

What is the lifetime of JNI localrefs for C++ calling Java?

From Dev

Is calling AttachCurrentThread on JNI costly?

From Dev

Calling swift from obj c

From Dev

Calling C++ from clojure

From Java

calling assembly functions from c

From Dev

Calling Haskell from c++

From Dev

Calling C printf from assembly

From Dev

calling c function from MATLAB?

Related Related

HotTag

Archive