0

我正在尝试使用原子算术函数在 RenderScript 中实现一个简单的亮度直方图rsAtomicInc,但我得到一个运行时错误,似乎说该函数不存在: ScriptC sym lookup failed for _Z11rsAtomicIncPVj

(要验证这是正确的符号,您可以使用:

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

dumpbin可以nm在 Windows 上替换。)我尝试使用其他原子函数,它们会产生类似的错误。无论我是在内核还是可调用函数中使用它们,我都会收到错误消息。

 // 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

错误日志:

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)
...

关于 histogram.o.info 的第一个错误可能是虚假的 - 完全卸载应用程序使其(但没有其他错误)在第一次运行时消失。

4

1 回答 1

1

这看起来像是我们的一个错误(Android RenderScript 团队)。看起来这些函数在我们实现的运行时库中不存在(即使它们存在于标头中)。我将在内部提交一个错误并为将来的版本进行清理。

于 2013-11-05T08:40:31.117 回答