Skip to content

HPC-ULL/FancyJCL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FancyJCL

Release

Description

This android module uses the Fancier High-Performance library to allow execution of OpenCL kernels on the GPU from Java or Kotlin. It is not just an OpenCL wrapper, since it takes care of all the glue code that is needed to initialize, transfer memory, create programs and kernels and manage the OpenCL execution queue.

Getting Started

Installation

To add this module in your android project:

  1. Add this in your root build.gradle at the end of repositories:
allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
  1. Add the dependency.
dependencies {
        implementation 'com.github.DoMondo:Fancier:Tag'
}

Usage

Say we want to add a constant to an existing Java byte array (byte []):

float kConstant = 95;
for (int i = 0; i < input.length; i++) {
    output[i] = input[i] + kConstant;
}

In order to use FancyJCL to execute this in GPU, we would rewrite it like so:

Stage stage = new Stage();
stage.setKernelSource("output[d0] = input[d0] * kConstant;");
stage.setInputs(Map.of("input", input, "kConstant", kConstant));
stage.setOutputs(Map.of("output", output));
stage.setRunConfiguration(new RunConfiguration(new long[]{size}, new long[]{4}));
stage.runSync();

For more complex scenarios, check the tutorials

Example application

An application that tests and benchmarks many image filters is located in examples/example_app.

Documentation

Check the Javadocs.