This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <jni.h> | |
| #include "OCLRuntime.h" | |
| #define ARRAY_SIZE 256 | |
| using std::unique_ptr; | |
| using std::vector; | |
| /* allocating resource objects on heap, so they can be released in ad-hoc fashion*/ | |
| /* standard OpenCL resource, platform, context, device, membuffer, commandqueue */ | |
| static unique_ptr<std::vector<cl::Platform>> platforms; | |
| static unique_ptr<cl::Context> hybridContext; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) Install latest NDK and SDK | |
| 2) Unzip ndk archive to %NDK_ROOT%, sdk archive to %SDK_ROOT% | |
| 3) Setup your windows PATH environment variable to contain %NDK_ROOT%, and SDK path that contains adb command(normally located at %SDK_ROOT%/platform-tools | |
| Because I don't want to add new directories to System Path, so used following two one-time session command to add PATH: | |
| set PATH=%PATH%;C:\Users\liawei\Android Dev\adt-bundle-windows-x86_64-20130717\sdk\platform-tools | |
| set NDK_ROOT=C:\Users\liawei\android-ndk-r9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /******************************************************************************************************************* | |
| To use the following code you need to create a Java based android Project and cross-compile a test C executable on Linux/PC/Mac | |
| and Copy it to Asset Folder of your Android Project. Instruction on Cross-Compile can be found in | |
| http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html | |
| and | |
| http://www.ikravets.com/computer-life/programming/2014/01/18/an-android-cross-compiling-environment-on-windowsunix-like-systems-using-ndk | |
| The code used to run binary and fetch output from stdout is copied from stackoverflow post - | |
| http://stackoverflow.com/questions/4703131/is-it-possible-to-run-a-native-arm-binary-on-a-non-rooted-android-phone | |
| and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /************************************************************************************************************* | |
| Main Entry Point FFT_1D_Neon() | |
| Input Params: 1) float32_t * inOutArray | |
| -- 1D float array with length of 2 to the power of (numOfBits+1) (plus one because each elements contains both real and imaginary component) | |
| 2) uint32_t numOfBits | |
| **************************************************************************************************************/ | |
| #include <arm_neon.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /******************************************************************************************* | |
| * My work in progress Code for FFT on GPU | |
| * | |
| *******************************************************************************************/ | |
| //every shader needs folllowing lines | |
| #define GL3ES_VERSION_SEPC "#version 300 es \n" | |
| #define FP_PREC_SPEC "precision mediump float; \n" | |
| #define FS_LAYOUT_LINE "layout(location = 0) out vec4 fragColor; \n" | |
| #define L_(STMT) " " #STMT " \n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <math.h> | |
| #define FOREVER while(1){ (void)0; } | |
| #define PI 3.141592654f | |
| //this marco only usable by FFT_Compute() function assuming we already have var realComp, imagineComp defined | |
| //four inputs: real is real component value, imagine is imaginary component value | |
| //kn is muplication of time domain sample location n and frequency domain sample location k | |
| // sum is total number of samples in current stage (stageNumber*2) | |
| #define EXP_NEG_TWOPI_JAY_N_K_OVER_N(real, imagine, kn,sum) { realComp = real*cos(-2.0f*PI*kn/(float)sum)-imagine*sin(-2.0f*PI*kn/(float)sum); \ |