Skip to content

Instantly share code, notes, and snippets.

@gnail737
gnail737 / gist:1e91be1a4d6be7f7255d
Last active August 29, 2015 14:02
Temp code -- unique_ptr is so beautiful`
#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;
@gnail737
gnail737 / gist:a363b3c6b45e99881afd
Last active August 29, 2015 14:02
How to use GDB to debug NDK code in windows without cygwin/mingw
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
@gnail737
gnail737 / gist:9ad7fc93142513398889
Last active August 29, 2015 14:00
My test code to run native ARM C binaries on Android
/*******************************************************************************************************************
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
/*************************************************************************************************************
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>
@gnail737
gnail737 / GPU_Kernel.h
Created April 6, 2014 16:46
FFT Implementation on GPU
/*******************************************************************************************
* 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"
@gnail737
gnail737 / Cooley_Tukey_FFT.c
Last active October 18, 2018 19:02
My FFT implementation
#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); \