Opencl can't find gpu on ARM - android

I'm trying to run image processing app on android/ARM, using opencv's ocl module. In some case(android4.2.2/Qualcomm snapdragon msm8930/Adreno TM305), it runs well.
But in other cases(android4.4.2/rockchip RK3288/mali-T764; android4.4/sumsung exynos5410/powerVR SGX 544mp),there are problems. CV::ocl::getOpenCLDevice() shows there is no opencl platform or device.
I'm sure all three tested systems support opencl. Could anyone tell me what's the problem here? Thanks!

Well,I fixed the problem already. The problem is some android devices don't have opencl lib file libopencl.so in file system, or the file has a different name(for example, libgles_Mali.so). To use opencl, we should set environment first.
Specifically, add
setenv("OPENCV_OPENCL_BINARY", "libGLES_Mali.so", 0);
Before
cv::ocl::getOpenCLDevices()

Related

Can not use Vulkan Subgroup operations in Android Studio

I'm writing a Vulkan compute shader in Android studio and launching it on Android phone. The problem I'm experiencing is next - I can not use any subgroup operations like subgroupAdd and subgroupElect. When I'm trying to use these functions I have an error like this:
reduce_vec.comp:35: error: 'subgroup op' : requires SPIR-V 1.3
I have checked - my Android phone supports subgroups, and my shader accepts such extensions:
#extension GL_KHR_shader_subgroup_arithmetic: enable
#extension GL_KHR_shader_subgroup_basic: enable
The problem is pretty much straightforward, I need to update my SPIR-V. But according to my findings, SPIR-V that comes automatically with Android studio is not something I can update easily.
Did someone experience a similar issue before? What was your solution? Thanks in advance!
Android solution
You can pass arguments to the Android shaderc compiler in your Gradle DSL:
https://developer.android.com/ndk/guides/graphics/shader-compilers
You need glslcArgs to contain --target-env=vulkan1.1
Flexible solution
Build your own compilation pipeline to compile from source into SPIR-V, and then include the SPIR-V binary files directly into your Android project.
There are multiple language front-ends that can generate SPIR-V, for GLSL the Khronos tools are here:
https://github.com/KhronosGroup/glslang

FFMPEG issues for android lollipop. error: only position independent executables (PIE) are supported

I was using the FFmpeg library in my application from the last 2 years and it still working fine on old version. It wont even work on android lollipop.
I was using these library before.
String[] libraryAssets = { "ffmpeg", "libavcodec-55.so", "libavcodec.so",
"libavfilter-4.so", "libavfilter.so", "libavformat-55.so",
"libavformat.so", "libavutil-52.so", "libavutil.so",
"libswresample-0.so", "libswresample.so", "libswscale-2.so",
"libswscale.so"
};
And I have got the answer from other link that if we use these 3 libraries it will work on lollipop aswell
"liblicense-jni.so,","libloader-jni.so","libvideokit.so"
But still It didnot resolve yet.
Please check this log.
***Starting FFMPEG***
***error: only position independent executables (PIE) are supported.***
***Ending FFMPEG***
Any help or any update in library ??
You can find FFmpeg for Android compiled with x264, libass, fontconfig, freetype and fribidi (Supports Android L) with compile guidance here.
And if you are facing difficulty compiling it, you can use pre-compiled library here.
Since API 21 the executables you run are required to be compiled as PIE. This is meant to improve the usage of memory as PIE or PIC (position-independent code) can be in loaded in any memory address, so that it does not overlap.
To compile ffmpeg as PIE you need to get the latest NDK, and built it. On older NDK's you had to provide the PIE option, but the new one does this by default.

Is there a way to run helgrind/drd in android?

I try to figure out some problem caused by thread sync in mips android, I installed valgrind in my mips machine, It is ok when using memcheck, but when I changed the option to --tool=helgrind, logcat says this:
I/start_valgrind.sh( 9328): link_image[2207]: 9329 could not load needed library '/data/local/Inst/lib/valgrind/vgpreload_drd-mips32-linux.so' for '/system/bin/app_process' (mips_relocate_got[1749]: 9329 cannot locate 'sched_yield'...
I located sched_yield in /system/lib/libc.so, but I can't find a way to add it to the link path; I using valgrind-3.10.0 and my android system version is 4.1.
So is it possible to run helgrind/drd in android? Thanks!

Problems with build.xml when using the Android ADK to communicate with an Arduino Mega ADK

So a few days ago I got my hands on an Arduino Mega ADK board, and the last couple of nights I have been setting up my development environment, getting to grips with the tools etc. The tools and libraries all work fine, for example I can get a program written in the Processing IDE to compile and run on an Asus Eee Pad Transformer TF101 running Android 4.03. But when I get it to try to compile and run one of the pre-written examples, it gives me a compiler error:
Android SDK Tools Revision 20
Installed at C:\NVPACK\android-sdk-windows
Project Type: Application
Project Target: Android 2.3.3
API level: 10
Library dependencies:
No Libraries
API<=15: Adding annotations.jar to the classpath.
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
No AIDL files to compile.
No RenderScript files to compile.
Generating resource IDs...
Generating BuildConfig class.
BUILD FAILED
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:680: The following error occurred while executing this line:
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:693: Compile failed; see the compiler error output for details.
Total time: 7 seconds
And that's all the console seems to output as well, which is rather frustrating! As far as I'm aware all of my SDK versions, tools and plugins are all up to date. I've tried this using a Linux partition I have on my hard drive and it produces the same error message, although it mentions a problem with the package com.Android.future.UsbAccessory. Given what I've seen, it seems that the problem is with the tools, either my directory structure doesn't match up to what the correct setup is, or something else is wrong :S. If anyone has had similar problems, some help would be smashing! (For the record, my setup was done using the instructions on the Arduino website, although I already had the Android SDK tools installed).
Will Scott-Jackson
It sounds like your haven't added in the support library to your project and/or you haven't downloaded it into your Android SDK.
The ADK1 demokit app targets API Level 10 (Android 2.3.3); That means you need to use the support libraries in your project and that's why the compiler is complaining about level 10 library dependencies not being available. The support libraries are a separate download in the SDK Manager, so you might not have them in your development environment.
In Android API Level 12 and higher, the USB Accessory protocol was added to the framework API, so there are two different ways to use the accessory protocol. So, you don't have to use the support libraries if you are targeting Honeycomb and higher versions, but you'll have to update the demokit app code to make this work.
Hope this helps.
So I've double checked my setup and started working on a project I had in mind, it seems to import the libraries appropriately. So far so good, but when I input:
ArduinoAdkUsb arduino;
void setup() {
arduino = new ArduinoAdkUsb(this);
//Other UI initialisation etc.
}
I get this error:
##name## ##version## by ##author##
FATAL EXCEPTION: Animation Thread
java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager
at cc.arduino.ADKCommunication.<init>(Unknown Source)
at cc.arduino.ArduinoAdkUsb.<init>(Unknown Source)
at
processing.android.test.sketch_120730a.
sketch_120730a.setup(sketch_120730a.java:48)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:856)
After the app has been built and installed onto the Android tablet I am using. Any thoughts how I can over come this? From what I can tell, this has no problem finding com.android.future.usb.manager to compile and install the program, but once it tries to run it can find it.
Based on this tutorial from http://stream.tellart.com/controlling-arduino-with-android/
In the examples RGB_Arduino the name, version and author variables are set at the top of the sketch.
Try adding in this section of code at the top of your arduino sketch just underneath the library imports
// accessory descriptor. It's how Arduino identifies itself to Android
char applicationName[] = "Mega_ADK"; // the app on your phone
char accessoryName[] = "Mega_ADK"; // your Arduino board
char companyName[] = "Freeware";
// make up anything you want for these
char versionNumber[] = "1.0";
char serialNumber[] = "1";
char url[] = "http://labs.arduino.cc/adk/"; // the URL of your app online
//initialize the accessory:
AndroidAccessory usb(companyName, applicationName,
accessoryName,versionNumber,url,serialNumber);

Android crashing on specific device - caused by int64 allocation

I'm having a problem that only seems to happen on my Lenovo Thinkpad Tablet running Android OS 3.1. I am running a native app using the NDK. The application runs fine in the emulator and on other devices.
Whenever I allocate an int64_t (defined as long long) I get a SIGILL crash with signal (4). As an example these lines will crash on the device.
int64_t i = 0;
long long j = 0;
I should note, the application runs fine, I can see menus rendering correctly, animating and waiting for input. When I touch, I allocate int64 variables for the timestamps, this is when the crash occurs. Regardless of where I allocate an int64 in this app, I get a crash.
The strange thing is, I loaded up the native-activity sample that comes with the NDK and tried allocating the above data types and it works fine. Both applications have the same Application.mk and very similar Android.mk files. I have also tried cleaning the project.
I am really unsure of what to look at next.
I have solved the problem. This project is a port from an iOS project which has some NEON math classes in it. We use the following flags for NEON support:
-mfpu=neon -mfloat-abi=softfp
We used the same flags in the Android project initially which worked initially. Although as soon as we got a new test device (Lenovo Thinkpad Tablet) we started getting the crash as above. Since building for armeabi-v5 worked and doesn't use NEON I knew it was related. It turns out there are better ways to compile for NEON for Android than using the above flags. I removed the above flags so that our Android.mk looks like so:
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS += -DHAS_NEON=1
MY_SRC_FILES += myfile.cpp.neon
else
LOCAL_CFLAGS += -DHAS_NEON=0
MY_SRC_FILES += myfile.cpp
endif
This means that only the files that actually need to be built for NEON are. The processor inside the Lenovo Thinkpad Tablet (Nvidia Tegra 2) doesn't support NEON so clearly building all files with NEON support was generating the instructions in a way which the processor didn't like.
Thanks for Keith for suggesting that I try the other architectures which led me to my solution.
Sounds like your compiler is generating 64-bit instructions that are not implemented by the processor on your machine. Are you cross-compiling? If so, make sure you're targeting the correct version of the ARM (x86?) chip in your tablet.

Categories

Resources