├── rapidDemoApp ├── src │ └── main │ │ ├── jni │ │ ├── Application.mk │ │ ├── kot.c │ │ ├── Android.mk │ │ ├── hello-jni.c │ │ ├── GmpUtil.h │ │ └── GmpUtil.c │ │ ├── assets │ │ ├── keystore.bks │ │ ├── ca_truststore.bks │ │ ├── rapid-qos.xml │ │ └── cuda-kernels │ │ │ └── matrixMul_kernel64.ptx │ │ ├── res │ │ ├── drawable │ │ │ ├── prove.jpg │ │ │ └── prove2.jpg │ │ ├── drawable-hdpi │ │ │ ├── icon.png │ │ │ └── icon_dark.png │ │ ├── drawable-ldpi │ │ │ ├── icon.png │ │ │ └── icon_dark.png │ │ ├── drawable-mdpi │ │ │ ├── icon.png │ │ │ └── icon_dark.png │ │ ├── drawable-xhdpi │ │ │ ├── icon.png │ │ │ └── icon_dark.png │ │ ├── values-sw600dp │ │ │ └── dimens.xml │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── style.xml │ │ │ ├── arrays.xml │ │ │ └── strings.xml │ │ ├── menu │ │ │ └── main.xml │ │ ├── values-sw720dp-land │ │ │ └── dimens.xml │ │ └── layout │ │ │ ├── activity_main.xml │ │ │ └── main.xml │ │ ├── java │ │ └── eu │ │ │ └── project │ │ │ └── rapid │ │ │ ├── synthBenchmark │ │ │ ├── JniTest.java │ │ │ └── TestRemoteable.java │ │ │ ├── demo │ │ │ ├── MainActivity.java │ │ │ └── DemoActivity.java │ │ │ ├── sudoku │ │ │ └── Sudoku.java │ │ │ ├── queens │ │ │ └── NQueens.java │ │ │ └── gvirtus │ │ │ └── MatrixMul.java │ │ └── AndroidManifest.xml ├── libs │ ├── core-1.51.0.0.jar │ ├── prov-1.51.0.0.jar │ └── commons-compress-1.9.jar ├── lint.xml └── build.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── runConfigurations.xml ├── compiler.xml ├── modules.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── .gitignore ├── gradlew.bat ├── gradlew └── README.md /rapidDemoApp/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi armeabi-v7a x86 x86_64 -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /rapidDemoApp/libs/core-1.51.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/libs/core-1.51.0.0.jar -------------------------------------------------------------------------------- /rapidDemoApp/libs/prov-1.51.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/libs/prov-1.51.0.0.jar -------------------------------------------------------------------------------- /rapidDemoApp/src/main/assets/keystore.bks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/assets/keystore.bks -------------------------------------------------------------------------------- /rapidDemoApp/libs/commons-compress-1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/libs/commons-compress-1.9.jar -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable/prove.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable/prove.jpg -------------------------------------------------------------------------------- /rapidDemoApp/src/main/assets/ca_truststore.bks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/assets/ca_truststore.bks -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable/prove2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable/prove2.jpg -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable-hdpi/icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable-hdpi/icon_dark.png -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable-ldpi/icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable-ldpi/icon_dark.png -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable-mdpi/icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable-mdpi/icon_dark.png -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/drawable-xhdpi/icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidProjectH2020/rapid-android-DemoApp/HEAD/rapidDemoApp/src/main/res/drawable-xhdpi/icon_dark.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':rapidDemoApp' 2 | include ':rapid-android-ac' 3 | project(':rapid-android-ac').projectDir = new File('../rapid-android/rapid-android-ac/') 4 | include ':rapid-gvirtus4a' 5 | project(':rapid-gvirtus4a').projectDir = new File('../rapid-android/rapid-gvirtus4a/') -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Mar 20 17:55:29 CET 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | org.gradle.jvmargs=-Xmx1024M -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/assets/rapid-qos.xml: -------------------------------------------------------------------------------- 1 | 2 | TODO 3 | 4 | /Users/sokol/Desktop/test/demo/JniTest.java 5 | 6 | localjniCaller 7 | 8 | true 9 | 10 | 11 | cpu_util 12 | LT 13 | 90 14 | mem_util 15 | LT 16 | 80 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /rapidDemoApp/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/jni/kot.c: -------------------------------------------------------------------------------- 1 | __global__ void add( int *a, int *b, int *c ) { 2 | *c = *a + *b; 3 | } 4 | 5 | int main( void ) { 6 | int a, b, c; // host copies of a, b, c 7 | int *dev_a, *dev_b, *dev_c; // device copies of a, b, c 8 | int size = sizeof( int ); // we need space for an integer 9 | 10 | // allocate device copies of a, b, c 11 | cudaMalloc( (void**)&dev_a, size ); 12 | cudaMalloc( (void**)&dev_b, size ); 13 | cudaMalloc( (void**)&dev_c, size ); 14 | 15 | a = 2; 16 | b = 7; 17 | 18 | // copy inputs to device 19 | cudaMemcpy( dev_a, &a, size, cudaMemcpyHostToDevice ); 20 | cudaMemcpy( dev_b, &b, size, cudaMemcpyHostToDevice ); 21 | 22 | // launch add() kernel on GPU, passing parameters 23 | add<<< 1, 1 >>>( dev_a, dev_b, dev_c ); 24 | 25 | // copy device result back to host copy of c 26 | cudaMemcpy( &c, dev_c, size, cudaMemcpyDeviceToHost ); 27 | cudaFree( dev_a ); 28 | cudaFree( dev_b ); 29 | cudaFree( dev_c ); 30 | 31 | return 0; 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS X 2 | .DS_Store 3 | 4 | # Built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # Files for the ART/Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | out/ 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | 29 | # Log Files 30 | *.log 31 | 32 | # Android Studio Navigation editor temp files 33 | .navigation/ 34 | 35 | # Android Studio captures folder 36 | captures/ 37 | 38 | # Intellij 39 | *.iml 40 | .idea/workspace.xml 41 | .idea/tasks.xml 42 | .idea/gradle.xml 43 | .idea/dictionaries 44 | .idea/libraries 45 | 46 | # Keystore files 47 | *.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | LOCAL_PATH := $(call my-dir) 17 | 18 | include $(CLEAR_VARS) 19 | 20 | LOCAL_CFLAGS := -DANDROID_NDK 21 | 22 | LOCAL_MODULE := hello-jni 23 | LOCAL_SRC_FILES := hello-jni.c 24 | 25 | include $(BUILD_SHARED_LIBRARY) 26 | 27 | #include $(CLEAR_VARS) 28 | 29 | #LOCAL_CFLAGS := -DANDROID_NDK 30 | 31 | #LOCAL_MODULE := jpargmp 32 | #LOCAL_SRC_FILES := GmpUtil.c 33 | 34 | #include $(BUILD_SHARED_LIBRARY) 35 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 21 | 16dp 22 | 16dp 23 | 24 | 25 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 24 | 128dp 25 | 26 | 27 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/values/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 26 | -------------------------------------------------------------------------------- /rapidDemoApp/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "25.0.3" 6 | 7 | defaultConfig { 8 | applicationId "eu.project.rapid.demo" 9 | minSdkVersion 19 10 | targetSdkVersion 26 11 | 12 | ndk { 13 | moduleName "hello-jni" 14 | } 15 | } 16 | 17 | buildTypes { 18 | debug { 19 | minifyEnabled false 20 | useProguard false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 22 | } 23 | release { 24 | minifyEnabled false 25 | useProguard false 26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 27 | } 28 | } 29 | externalNativeBuild { 30 | ndkBuild { 31 | path 'src/main/jni/Android.mk' 32 | } 33 | } 34 | 35 | lintOptions { 36 | checkReleaseBuilds false 37 | abortOnError false 38 | } 39 | } 40 | 41 | dependencies { 42 | // The libraries are imported in settings.gradle when developing locally. 43 | // Uncomment the following lines if you are just a user. 44 | // compile 'eu.project.rapid:rapid-android-ac:0.0.9' 45 | // compile 'eu.project.rapid:rapid-gvirtus4a:0.0.2' 46 | compile project(':rapid-android-ac') 47 | compile project(':rapid-gvirtus4a') 48 | compile files('libs/core-1.51.0.0.jar') 49 | compile files('libs/prov-1.51.0.0.jar') 50 | } 51 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/jni/hello-jni.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (C) 2015, 2016 RAPID EU Project 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | *******************************************************************************/ 18 | #include 19 | #include 20 | 21 | 22 | 23 | /* This is a trivial JNI example where we use a native method 24 | * to return a new VM String. 25 | */ 26 | 27 | //JavaVM *g_vm; // Can't have globals - SIGSEGV on server 28 | 29 | JNIEXPORT jstring JNICALL 30 | Java_eu_project_rapid_synthBenchmark_JniTest_stringFromJNI( JNIEnv* env, 31 | jobject thiz ) 32 | { 33 | return (*env)->NewStringUTF(env, "Hello from JNI 7!"); 34 | } 35 | 36 | jint JNI_OnLoad(JavaVM* vm, void* reserved) 37 | { 38 | //g_vm = vm; 39 | return JNI_VERSION_1_4; 40 | } 41 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 1.8 38 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/java/eu/project/rapid/synthBenchmark/JniTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (C) 2015, 2016 RAPID EU Project 3 | * 4 | * This library is free software; you can redistribute it and/or modify it under the terms of the 5 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 6 | * 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 9 | * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License along with this library; 13 | * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 14 | * 02110-1301 USA 15 | *******************************************************************************/ 16 | package eu.project.rapid.synthBenchmark; 17 | 18 | import android.util.Log; 19 | 20 | import java.lang.reflect.Method; 21 | 22 | import eu.project.rapid.ac.DFE; 23 | import eu.project.rapid.ac.Remoteable; 24 | 25 | public class JniTest extends Remoteable { 26 | private static final long serialVersionUID = 7407706990063388777L; 27 | 28 | private transient DFE dfe; 29 | 30 | public JniTest(DFE dfe) { 31 | this.dfe = dfe; 32 | } 33 | 34 | /* 35 | * A native method that is implemented by the 'hello-jni' native library, which is packaged with 36 | * this application. 37 | */ 38 | public native String stringFromJNI(); 39 | 40 | static { 41 | try { 42 | System.loadLibrary("hello-jni"); 43 | } catch (UnsatisfiedLinkError e) { 44 | Log.i("JniTest", "Could not load native library, maybe this is running on the VM."); 45 | } 46 | } 47 | 48 | public String jniCaller() { 49 | Method toExecute; 50 | String result = null; 51 | try { 52 | toExecute = this.getClass().getDeclaredMethod("localjniCaller", (Class[]) null); 53 | result = (String) dfe.execute(toExecute, this); 54 | } catch (SecurityException e) { 55 | // Should never get here 56 | e.printStackTrace(); 57 | throw e; 58 | } catch (NoSuchMethodException e) { 59 | // Should never get here 60 | e.printStackTrace(); 61 | } catch (Throwable e) { 62 | // TODO Auto-generated catch block 63 | e.printStackTrace(); 64 | } 65 | return result; 66 | } 67 | 68 | public String localjniCaller() { 69 | return stringFromJNI(); 70 | } 71 | 72 | @Override 73 | public void copyState(Remoteable arg0) { 74 | // TODO Auto-generated method stub 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 42 | 43 | 46 | 47 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 1 Clone 24 | 2 Clones 25 | 4 Clones 26 | 8 Clones 27 | 28 | 29 | 30 | 1 31 | 2 32 | 4 33 | 8 34 | 35 | 36 | 37 | 1 38 | 2 39 | 4 40 | 8 41 | 42 | 43 | 44 | 4 Queens 45 | 5 Queens 46 | 6 Queens 47 | 7 Queens 48 | 8 Queens 49 | 50 | 51 | 52 | 4 53 | 5 54 | 6 55 | 7 56 | 8 57 | 58 | 59 | 60 | 4 61 | 5 62 | 6 63 | 7 64 | 8 65 | 66 | 67 | 68 | 1 69 | 10 70 | 100 71 | 1000 72 | 73 | 74 | 75 | -1 76 | 0 77 | 100 78 | 256 79 | 512 80 | 768 81 | 1000 82 | 2000 83 | 4000 84 | 6000 85 | 8000 86 | 10000 87 | 88 | 89 | 90 | "-1" 91 | "0" 92 | "1" 93 | "2" 94 | "3" 95 | "4" 96 | "5" 97 | "6" 98 | "7" 99 | 100 | 101 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/jni/GmpUtil.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (C) 2015, 2016 RAPID EU Project 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | *******************************************************************************/ 18 | /* DO NOT EDIT THIS FILE - it is machine generated */ 19 | #include 20 | /* Header for class GmpUtil */ 21 | 22 | #ifndef _Included_GmpUtil 23 | #define _Included_GmpUtil 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | /* 28 | * Class: GmpUtil 29 | * Method: mpz_init 30 | * Signature: ()J 31 | */ 32 | JNIEXPORT jlong JNICALL Java_GmpUtil_mpz_1init 33 | (JNIEnv *, jclass); 34 | 35 | /* 36 | * Class: GmpUtil 37 | * Method: mpz_clear 38 | * Signature: (J)V 39 | */ 40 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1clear 41 | (JNIEnv *, jclass, jlong); 42 | 43 | /* 44 | * Class: GmpUtil 45 | * Method: mpz_set_si 46 | * Signature: (JI)V 47 | */ 48 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1set_1si 49 | (JNIEnv *, jclass, jlong, jint); 50 | 51 | /* 52 | * Class: GmpUtil 53 | * Method: mpz_get_si 54 | * Signature: (J)I 55 | */ 56 | JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1get_1si 57 | (JNIEnv *, jclass, jlong); 58 | 59 | /* 60 | * Class: GmpUtil 61 | * Method: mpz_cmp 62 | * Signature: (JJ)I 63 | */ 64 | JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1cmp 65 | (JNIEnv *, jclass, jlong, jlong); 66 | 67 | /* 68 | * Class: GmpUtil 69 | * Method: mpz_add 70 | * Signature: (JJJ)V 71 | */ 72 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1add 73 | (JNIEnv *, jclass, jlong, jlong, jlong); 74 | 75 | /* 76 | * Class: GmpUtil 77 | * Method: mpz_sub 78 | * Signature: (JJJ)V 79 | */ 80 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1sub 81 | (JNIEnv *, jclass, jlong, jlong, jlong); 82 | 83 | /* 84 | * Class: GmpUtil 85 | * Method: mpz_mul_si 86 | * Signature: (JJI)V 87 | */ 88 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1mul_1si 89 | (JNIEnv *, jclass, jlong, jlong, jint); 90 | 91 | /* 92 | * Class: GmpUtil 93 | * Method: mpz_addmul_ui 94 | * Signature: (JJI)V 95 | */ 96 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1addmul_1ui 97 | (JNIEnv *x, jclass y, jlong dest, jlong a, jint b); 98 | 99 | /* 100 | * Class: GmpUtil 101 | * Method: mpz_submul_ui 102 | * Signature: (JJI)V 103 | */ 104 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1submul_1ui 105 | (JNIEnv *x, jclass y, jlong dest, jlong a, jint b); 106 | 107 | /* 108 | * Class: GmpUtil 109 | * Method: mpz_divexact 110 | * Signature: (JJJ)V 111 | */ 112 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1divexact 113 | (JNIEnv *, jclass, jlong, jlong, jlong); 114 | 115 | /* 116 | * Class: GmpUtil 117 | * Method: mpz_tdiv_qr 118 | * Signature: (JJJJ)V 119 | */ 120 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1tdiv_1qr 121 | (JNIEnv *, jclass, jlong, jlong, jlong, jlong); 122 | 123 | /* 124 | * Class: GmpUtil 125 | * Method: mpz_gcd 126 | * Signature: (JJJ)V 127 | */ 128 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1gcd 129 | (JNIEnv *, jclass, jlong, jlong, jlong); 130 | 131 | #ifdef __cplusplus 132 | } 133 | #endif 134 | #endif -------------------------------------------------------------------------------- /rapidDemoApp/src/main/java/eu/project/rapid/synthBenchmark/TestRemoteable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (C) 2015, 2016 RAPID EU Project 3 | * 4 | * This library is free software; you can redistribute it and/or modify it under the terms of the 5 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 6 | * 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 9 | * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License along with this library; 13 | * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 14 | * 02110-1301 USA 15 | *******************************************************************************/ 16 | package eu.project.rapid.synthBenchmark; 17 | 18 | import java.lang.reflect.Method; 19 | import java.util.Random; 20 | 21 | import eu.project.rapid.ac.DFE; 22 | import eu.project.rapid.ac.Remoteable; 23 | 24 | /** 25 | * Simple class that tests offloading for trivial applications. 26 | */ 27 | public class TestRemoteable extends Remoteable { 28 | private static final long serialVersionUID = 1L; 29 | 30 | private transient DFE dfe; 31 | 32 | public TestRemoteable(DFE dfe) { 33 | this.dfe = dfe; 34 | } 35 | 36 | public String cpuLoader1() { 37 | Method toExecute; 38 | String result = ""; 39 | try { 40 | toExecute = this.getClass().getDeclaredMethod("localCpuLoader1", (Class[]) null); 41 | result = (String) dfe.execute(toExecute, this); 42 | } catch (SecurityException e) { 43 | e.printStackTrace(); 44 | throw e; 45 | } catch (NoSuchMethodException e) { 46 | e.printStackTrace(); 47 | } catch (Throwable e) { 48 | e.printStackTrace(); 49 | } 50 | return result; 51 | } 52 | 53 | public String localCpuLoader1() { 54 | for (int i = 0; i < 10000; i++) { 55 | } 56 | return "cpuLoader1 finished"; 57 | } 58 | 59 | public String cpuLoader2() { 60 | Method toExecute; 61 | String result = ""; 62 | try { 63 | toExecute = this.getClass().getDeclaredMethod("localCpuLoader2", (Class[]) null); 64 | result = (String) dfe.execute(toExecute, this); 65 | } catch (SecurityException e) { 66 | // Should never get here 67 | e.printStackTrace(); 68 | throw e; 69 | } catch (NoSuchMethodException e) { 70 | // Should never get here 71 | e.printStackTrace(); 72 | } catch (Throwable e) { 73 | // TODO Auto-generated catch block 74 | e.printStackTrace(); 75 | } 76 | return result; 77 | } 78 | 79 | public Long cpuLoader3(int seed) { 80 | Method toExecute; 81 | Class[] paramTypes = {int.class}; 82 | Object[] paramValues = {seed}; 83 | Long result = null; 84 | try { 85 | toExecute = this.getClass().getDeclaredMethod("localCpuLoader3", paramTypes); 86 | result = (Long) dfe.execute(toExecute, paramValues, this); 87 | } catch (SecurityException e) { 88 | // Should never get here 89 | e.printStackTrace(); 90 | throw e; 91 | } catch (NoSuchMethodException e) { 92 | // Should never get here 93 | e.printStackTrace(); 94 | } catch (Throwable e) { 95 | // TODO Auto-generated catch block 96 | e.printStackTrace(); 97 | } 98 | return result; 99 | } 100 | 101 | public String localCpuLoader2() { 102 | for (int i = 0; i < 500000; i++) { 103 | } 104 | return "cpuLoader2 finished"; 105 | } 106 | 107 | public Long localCpuLoader3(int seed) { 108 | Random rand = new Random(seed); 109 | return rand.nextLong(); 110 | } 111 | 112 | @Override 113 | public void copyState(Remoteable state) { 114 | // No fields to restore 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/jni/GmpUtil.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (C) 2015, 2016 RAPID EU Project 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | *******************************************************************************/ 18 | #include "GmpUtil.h" 19 | #include "gmp.h" 20 | 21 | /* 22 | * Class: GmpUtil 23 | * Method: mpz_init 24 | * Signature: ()J 25 | */ 26 | JNIEXPORT jlong JNICALL Java_GmpUtil_mpz_1init 27 | (JNIEnv *x, jclass y) 28 | { 29 | mpz_t *p = malloc( sizeof(__mpz_struct) ); 30 | __gmpz_init( *p ); 31 | 32 | return (jlong)p; 33 | } 34 | 35 | /* 36 | * Class: GmpUtil 37 | * Method: mpz_clear 38 | * Signature: (J)V 39 | */ 40 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1clear 41 | (JNIEnv *x, jclass y, jlong o) 42 | { 43 | mpz_t* p = (mpz_t*)o; 44 | __gmpz_clear( *p ); 45 | free( p ); 46 | } 47 | 48 | /* 49 | * Class: GmpUtil 50 | * Method: mpz_set_si 51 | * Signature: (JI)V 52 | */ 53 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1set_1si 54 | (JNIEnv *x, jclass y, jlong dest, jint val) 55 | { 56 | __gmpz_set_si( *((mpz_t*)dest), (long) val); 57 | } 58 | 59 | /* 60 | * Class: GmpUtil 61 | * Method: mpz_get_si 62 | * Signature: (J)I 63 | */ 64 | JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1get_1si 65 | (JNIEnv *x, jclass y, jlong dest) 66 | { 67 | return (jint)__gmpz_get_si( *((mpz_t*)dest)); 68 | } 69 | 70 | /* 71 | * Class: GmpUtil 72 | * Method: mpz_cmp 73 | * Signature: (JJ)I 74 | */ 75 | JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1cmp 76 | (JNIEnv *x, jclass y, jlong op1, jlong op2) 77 | { 78 | return (jint) __gmpz_cmp( *((mpz_t*)op1), *((mpz_t*)op2) ); 79 | } 80 | 81 | /* 82 | * Class: GmpUtil 83 | * Method: mpz_add 84 | * Signature: (JJJ)V 85 | */ 86 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1add 87 | (JNIEnv *x, jclass y, jlong dest, jlong src, jlong val) 88 | { 89 | __gmpz_add( *((mpz_t*)dest), *((mpz_t*)src), *((mpz_t*)val) ); 90 | } 91 | 92 | /* 93 | * Class: GmpUtil 94 | * Method: mpz_sub 95 | * Signature: (JJJ)V 96 | */ 97 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1sub 98 | (JNIEnv *x, jclass y, jlong dest, jlong src, jlong val) 99 | { 100 | __gmpz_sub( *((mpz_t*)dest), *((mpz_t*)src), *((mpz_t*)val) ); 101 | } 102 | 103 | /* 104 | * Class: GmpUtil 105 | * Method: mpz_mul_si 106 | * Signature: (JJI)V 107 | */ 108 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1mul_1si 109 | (JNIEnv *x, jclass y, jlong dest, jlong src, jint val) 110 | { 111 | __gmpz_mul_si( *((mpz_t*)dest), *((mpz_t*)src), (long) val); 112 | } 113 | 114 | /* 115 | * Class: GmpUtil 116 | * Method: mpz_addmul_ui 117 | * Signature: (JJI)V 118 | */ 119 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1addmul_1ui 120 | (JNIEnv *x, jclass y, jlong dest, jlong a, jint b) 121 | { 122 | __gmpz_addmul_ui( *((mpz_t*)dest), *((mpz_t*)a), (long)b); 123 | } 124 | 125 | /* 126 | * Class: GmpUtil 127 | * Method: mpz_submul_ui 128 | * Signature: (JJI)V 129 | */ 130 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1submul_1ui 131 | (JNIEnv *x, jclass y, jlong dest, jlong a, jint b) 132 | { 133 | __gmpz_submul_ui( *((mpz_t*)dest), *((mpz_t*)a), (long)b); 134 | } 135 | 136 | /* 137 | * Class: GmpUtil 138 | * Method: mpz_divexact 139 | * Signature: (JJJ)V 140 | */ 141 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1divexact 142 | (JNIEnv *x, jclass y, jlong quot, jlong n, jlong d) 143 | { 144 | __gmpz_divexact( *((mpz_t*)quot), *((mpz_t*)n), *((mpz_t*)d)); 145 | } 146 | 147 | /* 148 | * Class: GmpUtil 149 | * Method: mpz_tdiv_qr 150 | * Signature: (JJJJ)V 151 | */ 152 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1tdiv_1qr 153 | (JNIEnv *x, jclass y, jlong q, jlong r, jlong n, jlong d) 154 | { 155 | __gmpz_tdiv_qr( *((mpz_t*)q), *((mpz_t*)r), *((mpz_t*)n), *((mpz_t*)d) ); 156 | } 157 | 158 | /* 159 | * Class: GmpUtil 160 | * Method: mpz_gcd 161 | * Signature: (JJJ)V 162 | */ 163 | JNIEXPORT void JNICALL Java_GmpUtil_mpz_1gcd 164 | (JNIEnv *x, jclass y, jlong r, jlong a, jlong b) 165 | { 166 | __gmpz_gcd( *((mpz_t*)r), *((mpz_t*)a), *((mpz_t*)b) ); 167 | } 168 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | RAPID Offloading Framework 23 | Test 1 24 | Test 2 25 | Test 3 26 | Scenario 1 27 | Scenario 2 28 | 29 | Benchmark Bundle 1 30 | Benchmark Bundle 2 31 | All Bundles 32 | Puzzle Scenarios 33 | Testing code offloading 34 | Choose what to optimize by offloading 35 | Face Detection 36 | Virus Scanning 37 | Solve Sudoku 38 | 39 | GVirtuS MatrixMul test 40 | Matrix multiplication using CUDA. 41 | The CUDA calls will be transparently offloaded to a remote GPU. 42 | 43 | Nr. local exec.: 44 | Avg. local (ms): 45 | Nr. remote exec.: 46 | Avg. remote (ms): 47 | 48 | Nr. of Queens: 49 | Solve NQueens 50 | Solve the NQueens puzzle. 51 | The higher the number of queens, the higher the execution time. 52 | 53 | JNI test 54 | 55 | This test shows the offloading of native methods implemented via JNI. 56 | It simply prints \"Hello from JNI\". 57 | 58 | Always Local 59 | Always Remote 60 | Energy 61 | Delay (Execution Time + Communication) 62 | Energy and Delay 63 | Local fraction [0, 1] 64 | Run All Experiments 65 | Number of VMs: 66 | Number of Photos: 67 | MainActivity 68 | Settings 69 | 70 | Use Rapid Infrastructure or Direct connection with VM 71 | With Rapid infrastructure 72 | Direct connection to VM 73 | 74 | Choose the communication type 75 | Clear communication 76 | SSL communication 77 | Choose from methods annotations 78 | 79 | Insert VM\'s IP 80 | Remember settings 81 | Choose the remote device 82 | Start 83 | Connect to new VM 84 | Connect to previous VM 85 | If this device was connected previously to a VM, then the Registration Manager will try to connect to that VM again. 86 | Connect to nearby mobile devices 87 | Device not connected to Internet!\nYou can\'t connect to remote VMs on the cloud, only to nearby mobile devices for D2D offloading. 88 | Connected to VM in Clear 89 | Connected to VM in SSL 90 | Not Connected to VM 91 | 92 | Testing DSE and DFE implementation 93 | Test DSE performance 94 | Download file from Manager 95 | Upload file to Manager 96 | Test connection, UL, and DL 97 | Choose data rate: 98 | Test sending bytes 1000 times to clone 99 | Test receiving bytes 1000 times from clone 100 | 101 | Check to enforce forwarding 102 | 103 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/java/eu/project/rapid/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (C) 2015, 2016 RAPID EU Project 3 | * 4 | * This library is free software; you can redistribute it and/or modify it under the terms of the 5 | * GNU Lesser General Public License as published by the Free Software Foundation; either version 6 | * 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 9 | * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License along with this library; 13 | * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 14 | * 02110-1301 USA 15 | *******************************************************************************/ 16 | package eu.project.rapid.demo; 17 | 18 | import android.app.Activity; 19 | import android.content.Context; 20 | import android.content.Intent; 21 | import android.content.SharedPreferences; 22 | import android.graphics.Color; 23 | import android.os.Bundle; 24 | import android.util.Log; 25 | import android.view.View; 26 | import android.widget.EditText; 27 | import android.widget.RadioGroup; 28 | import android.widget.RadioGroup.OnCheckedChangeListener; 29 | 30 | import java.security.Security; 31 | 32 | import eu.project.rapid.ac.RapidNetworkService; 33 | import eu.project.rapid.common.RapidConstants.COMM_TYPE; 34 | import eu.project.rapid.common.RapidUtils; 35 | 36 | /** 37 | * The main activity for the Android program. 38 | */ 39 | public class MainActivity extends Activity { 40 | 41 | private static final String TAG = "MainActivity"; 42 | public static final String KEY_VM_IP = "KEY_VM_IP"; 43 | public static final String KEY_USE_RAPID_INFRASTRUCTURE = "KEY_USE_RAPID_INFRASTRUCTURE"; 44 | public static final String KEY_CONN_TYPE = "KEY_CONN_TYPE"; 45 | public static final String KEY_USE_PREV_VM = "KEY_USE_PREV_VM"; 46 | 47 | private RadioGroup radioGroupStartAs; 48 | private RadioGroup radioGroupUseRapid; 49 | private EditText textVmIpAddress; 50 | private String vmIp; 51 | private COMM_TYPE commType = COMM_TYPE.SSL; 52 | private boolean connectToPrevVm = true; 53 | 54 | static { 55 | Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1); 56 | } 57 | 58 | /** 59 | * Called when the activity is first created. 60 | */ 61 | @Override 62 | public void onCreate(Bundle savedInstanceState) { 63 | super.onCreate(savedInstanceState); 64 | setContentView(R.layout.activity_main); 65 | 66 | radioGroupUseRapid = (RadioGroup) findViewById(R.id.radioGroupUseRapid); 67 | radioGroupUseRapid.setOnCheckedChangeListener(new OnUseRapidRadioChecked()); 68 | 69 | radioGroupStartAs = (RadioGroup) findViewById(R.id.radioGroupStartAs); 70 | radioGroupStartAs.setOnCheckedChangeListener(new OnStartAsRadioChecked()); 71 | 72 | textVmIpAddress = (EditText) findViewById(R.id.editTextIpAddress); 73 | SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); 74 | vmIp = prefs.getString(KEY_VM_IP, null); 75 | textVmIpAddress.setText(vmIp); 76 | } 77 | 78 | public void onRadioCommunicationTypeChecked(View radioButton) { 79 | 80 | switch (radioButton.getId()) { 81 | 82 | case R.id.radio_clear_communication: 83 | commType = COMM_TYPE.CLEAR; 84 | Log.i(TAG, "The communication UE-VM should be performed in clear"); 85 | break; 86 | 87 | case R.id.radio_ssl_communication: 88 | commType = COMM_TYPE.SSL; 89 | Log.i(TAG, "The communication UE-VM should be performed using SSL"); 90 | break; 91 | } 92 | } 93 | 94 | // Watch for button clicks 95 | public void onStartButton(View v) { 96 | Intent intent = new Intent(v.getContext(), DemoActivity.class); 97 | 98 | // If the user is setting the IP of the VM automatically, we should check that the IP is 99 | // correctly formatted. 100 | if (radioGroupUseRapid.getCheckedRadioButtonId() == R.id.radioUseRapidNo) { 101 | vmIp = textVmIpAddress.getText().toString(); 102 | 103 | if (!RapidUtils.validateIpAddress(vmIp)) { 104 | textVmIpAddress.setTextColor(Color.RED); 105 | } else { 106 | textVmIpAddress.setTextColor(Color.GREEN); 107 | Log.i(TAG, "Creating a connection with VM with IP: " + vmIp); 108 | intent.putExtra(KEY_VM_IP, vmIp); 109 | intent.putExtra(KEY_USE_RAPID_INFRASTRUCTURE, false); 110 | intent.putExtra(KEY_CONN_TYPE, commType); 111 | intent.putExtra(KEY_USE_PREV_VM, connectToPrevVm); 112 | SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); 113 | SharedPreferences.Editor editor = prefs.edit(); 114 | editor.putString(KEY_VM_IP, vmIp); 115 | editor.apply(); 116 | startActivity(intent); 117 | } 118 | } else { 119 | // Should use the Rapid infrastructure. 120 | intent.putExtra(KEY_USE_RAPID_INFRASTRUCTURE, true); 121 | startActivity(intent); 122 | } 123 | } 124 | 125 | private class OnStartAsRadioChecked implements OnCheckedChangeListener { 126 | public void onCheckedChanged(RadioGroup group, int checkedId) { 127 | 128 | switch (checkedId) { 129 | case R.id.radioStartAsNewVm: 130 | connectToPrevVm = false; 131 | RapidNetworkService.usePrevVm = false; 132 | break; 133 | 134 | case R.id.radioStartAsOldVm: 135 | connectToPrevVm = true; 136 | RapidNetworkService.usePrevVm = true; 137 | break; 138 | 139 | case R.id.radioStartAsD2D: 140 | break; 141 | } 142 | } 143 | } 144 | 145 | private class OnUseRapidRadioChecked implements OnCheckedChangeListener { 146 | 147 | public void onCheckedChanged(RadioGroup group, int checkedId) { 148 | switch (checkedId) { 149 | case R.id.radioUseRapidYes: 150 | textVmIpAddress.setVisibility(View.GONE); 151 | radioGroupStartAs.setVisibility(View.VISIBLE); 152 | break; 153 | 154 | case R.id.radioUseRapidNo: 155 | radioGroupStartAs.setVisibility(View.GONE); 156 | textVmIpAddress.setVisibility(View.VISIBLE); 157 | break; 158 | } 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /rapidDemoApp/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 25 | 26 | 32 | 33 | 34 | 35 | 43 | 44 | 49 | 50 | 56 | 57 | 62 | 63 | 64 | 65 | 74 | 75 | 76 | 77 | 81 | 82 | 88 | 89 | 94 | 95 | 101 | 102 | 103 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 126 | 127 | 133 | 134 | 141 | 142 | 148 | 149 | 150 | 151 | 152 | 153 | 178 | 179 | 180 | 192 | 193 |