0

I am trying to implement a simple luminance histogram in RenderScript using the atomic arithmetic function rsAtomicInc, but I get a runtime error which seems to say that function does not exist: ScriptC sym lookup failed for _Z11rsAtomicIncPVj.

(To verify that this is the correct symbol, you can use:

$ echo "unsigned int __attribute__((overloadable)) 
     rsAtomicInc ( volatile unsigned int *addr ) { return 0; }" > rsai.c
$ clang -c rsai.c; nm rsai.o

dumpbin can be substituted for nm on Windows.) I have tried using the other atomic functions, which yield similar errors. I get the errors regardless of whether I use them in a kernel or an invokable function.

 // histogram.rs:
 #pragma version(1)
 #pragma rs java_package_name(com.example.android.rs.hellocompute)
 #pragma rs_fp_imprecise //relax math- allows NEON and other optimizations

 const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
 volatile uint32_t *luminanceHistogram;

 void luminance(const uchar4 *img, const void *usrData, uint32_t x, uint32_t y) {
     float4 f4 = rsUnpackColor8888(*img);
     float3 mono = dot(f4.rgb, gMonoMult);
     uchar lum = rsPackColorTo8888(mono).r;
     rsAtomicInc(luminanceHistogram + lum);
 }

 void increment(int lum) {
     rsAtomicInc(luminanceHistogram + lum);
 }
 // HelloCompute.java
int[] luminance = new int[256];
Allocation luminanceHistogram = Allocation.createSized(mRS, 
    Element.U32(mRS), luminance.length);
ScriptC_histogram histo = new ScriptC_histogram(mRS); // ERROR

Error log:

E/bcc     ( 3539): Invalid RS info file /data/data/com.example.android.rs.hellocompute/cache/com.android.renderscript.cache/histogram.o.info! (No such file or directory)
E/RenderScript( 3539): ScriptC sym lookup failed for _Z11rsAtomicIncPVj
E/bcc     ( 3539): Some symbols are found to be undefined during relocation!
E/bcc     ( 3539): Error occurred when performs relocation on /data/data/com.example.android.rs.hellocompute/cache/com.android.renderscript.cache/histogram.o!
E/RenderScript( 3539): bcc: FAILS to prepare executable for 'histogram'
D/AndroidRuntime( 3539): Shutting down VM
W/dalvikvm( 3539): threadid=1: thread exiting with uncaught exception (group=0x415c6700)
E/AndroidRuntime( 3539): FATAL EXCEPTION: main
E/AndroidRuntime( 3539): android.renderscript.RSRuntimeException: Loading of ScriptC script failed.
E/AndroidRuntime( 3539):    at android.renderscript.ScriptC.<init>(ScriptC.java:60)
...

The first error concerning histogram.o.info is probably spurious- a complete uninstall of the app makes it (but none of the other errors) go away for the first run.

Kietz
  • 1,186
  • 11
  • 19

1 Answers1

1

This looks like a bug on our part (Android RenderScript team). It looks like those functions just don't exist in our implemented runtime library (even though they exist in the header). I will file a bug internally and get this cleaned up for future releases.

Stephen Hines
  • 2,612
  • 1
  • 13
  • 12
  • Did you manage to reproduce it? Is there any more information I could give that would help? Do you have any recommendations for a workaround? – Kietz Nov 05 '13 at 17:14
  • 1
    The only workaround is to not use the unsigned versions of these functions. There are signed variants that should work. – Stephen Hines Nov 05 '13 at 17:24
  • We just missed implementing these functions. It should be something we can fix easily for the next release, but we won't be able to do anything for earlier versions of Android. – Stephen Hines Nov 05 '13 at 18:36