├── Rapid-DemoApp
├── jni
│ ├── Application.mk
│ ├── Android.mk
│ ├── hello-jni.c
│ ├── GmpUtil.h
│ └── GmpUtil.c
├── res
│ ├── drawable
│ │ ├── icon.xcf
│ │ ├── 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
├── libs
│ ├── core-1.51.0.0.jar
│ ├── prov-1.51.0.0.jar
│ ├── x86
│ │ └── libhello-jni.so
│ ├── armeabi
│ │ └── libhello-jni.so
│ ├── commons-compress-1.9.jar
│ ├── x86_64
│ │ └── libhello-jni.so
│ └── armeabi-v7a
│ │ └── libhello-jni.so
├── .classpath
├── lint.xml
├── .externalToolBuilders
│ └── NDK Build.launch
├── .project
├── project.properties
├── src
│ └── eu
│ │ └── project
│ │ └── rapid
│ │ ├── synthBenchmark
│ │ ├── JniTest.java
│ │ └── TestRemoteable.java
│ │ ├── demo
│ │ └── MainActivity.java
│ │ └── sudoku
│ │ └── Sudoku.java
├── AndroidManifest.xml
└── .settings
│ └── org.eclipse.jdt.ui.prefs
├── AccelerationClient
├── lib
│ ├── antlr-2.7.7.jar
│ ├── javaparser-1.0.8.jar
│ └── stringtemplate-3.2.1.jar
├── src
│ └── eu
│ │ └── project
│ │ └── rapid
│ │ ├── ac
│ │ ├── RapidSettingsActivity.java
│ │ ├── profilers
│ │ │ ├── phone
│ │ │ │ ├── PhoneMotorolaMotoG.java
│ │ │ │ ├── PhoneFactory.java
│ │ │ │ ├── PhoneHtcDream.java
│ │ │ │ └── PhoneAlcatelOneTouchPixi.java
│ │ │ ├── LocationProfiler.java
│ │ │ ├── NetworkBWRecord.java
│ │ │ ├── LogRecord.java
│ │ │ └── Profiler.java
│ │ ├── QoS.java
│ │ ├── Remote.java
│ │ ├── ResultContainer.java
│ │ ├── Remoteable.java
│ │ ├── d2d
│ │ │ ├── D2DMessage.java
│ │ │ ├── PhoneSpecs.java
│ │ │ └── D2DClientService.java
│ │ ├── db
│ │ │ ├── DBEntry.java
│ │ │ └── DBCache.java
│ │ └── utils
│ │ │ ├── Constants.java
│ │ │ └── ZipHandler.java
│ │ └── gvirtusfe
│ │ ├── CudaDr_initialization.java
│ │ ├── dim3.java
│ │ ├── Result.java
│ │ ├── CudaDr_context.java
│ │ ├── CudaRt_memory.java
│ │ ├── CudaDr_execution.java
│ │ ├── CudaDr_memory.java
│ │ ├── CudaDr_module.java
│ │ ├── Buffer.java
│ │ ├── Frontend.java
│ │ └── CudaDr_device.java
├── .classpath
├── .project
├── files
│ └── template.st
├── project.properties
├── AndroidManifest.xml
└── .settings
│ └── org.eclipse.jdt.ui.prefs
├── AccelerationServer
├── res
│ ├── drawable
│ │ └── icon.png
│ ├── drawable-hdpi
│ │ └── icon.png
│ ├── drawable-ldpi
│ │ └── icon.png
│ ├── drawable-mdpi
│ │ └── icon.png
│ ├── values
│ │ └── string.xml
│ └── layout
│ │ └── main.xml
├── libs
│ ├── core-1.51.0.0.jar
│ └── prov-1.51.0.0.jar
├── .classpath
├── lint.xml
├── .project
├── project.properties
├── src
│ └── eu
│ │ └── project
│ │ └── rapid
│ │ └── as
│ │ ├── RapidServerActivity.java
│ │ ├── AccelerationServerAutoStarter.java
│ │ ├── DynamicObjectInputStream.java
│ │ └── NetworkProfilerServer.java
├── .settings
│ └── org.eclipse.jdt.ui.prefs
└── AndroidManifest.xml
└── README.md
/Rapid-DemoApp/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_ABI := armeabi armeabi-v7a x86 x86_64
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable/icon.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable/icon.xcf
--------------------------------------------------------------------------------
/AccelerationClient/lib/antlr-2.7.7.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationClient/lib/antlr-2.7.7.jar
--------------------------------------------------------------------------------
/Rapid-DemoApp/libs/core-1.51.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/libs/core-1.51.0.0.jar
--------------------------------------------------------------------------------
/Rapid-DemoApp/libs/prov-1.51.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/libs/prov-1.51.0.0.jar
--------------------------------------------------------------------------------
/Rapid-DemoApp/libs/x86/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/libs/x86/libhello-jni.so
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable/prove.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable/prove.jpg
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable/prove2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable/prove2.jpg
--------------------------------------------------------------------------------
/AccelerationServer/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationServer/res/drawable/icon.png
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/AccelerationClient/lib/javaparser-1.0.8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationClient/lib/javaparser-1.0.8.jar
--------------------------------------------------------------------------------
/AccelerationServer/libs/core-1.51.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationServer/libs/core-1.51.0.0.jar
--------------------------------------------------------------------------------
/AccelerationServer/libs/prov-1.51.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationServer/libs/prov-1.51.0.0.jar
--------------------------------------------------------------------------------
/Rapid-DemoApp/libs/armeabi/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/libs/armeabi/libhello-jni.so
--------------------------------------------------------------------------------
/Rapid-DemoApp/libs/commons-compress-1.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/libs/commons-compress-1.9.jar
--------------------------------------------------------------------------------
/Rapid-DemoApp/libs/x86_64/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/libs/x86_64/libhello-jni.so
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/AccelerationServer/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationServer/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/AccelerationServer/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationServer/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/AccelerationServer/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationServer/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable-hdpi/icon_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable-hdpi/icon_dark.png
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable-ldpi/icon_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable-ldpi/icon_dark.png
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable-mdpi/icon_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable-mdpi/icon_dark.png
--------------------------------------------------------------------------------
/AccelerationClient/lib/stringtemplate-3.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/AccelerationClient/lib/stringtemplate-3.2.1.jar
--------------------------------------------------------------------------------
/Rapid-DemoApp/libs/armeabi-v7a/libhello-jni.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/libs/armeabi-v7a/libhello-jni.so
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/drawable-xhdpi/icon_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RapidProjectH2020/offloading-framework-android/HEAD/Rapid-DemoApp/res/drawable-xhdpi/icon_dark.png
--------------------------------------------------------------------------------
/AccelerationClient/src/eu/project/rapid/ac/RapidSettingsActivity.java:
--------------------------------------------------------------------------------
1 | package eu.project.rapid.ac;
2 |
3 | /**
4 | * This activity will have the appropriate buttons to control the settings of the
5 | * AccelerationClient.
6 | * It will be be used to start and stop the D2DClientService, for example, and for much more.
7 | *
8 | * @author sokol
9 | *
10 | */
11 | public class RapidSettingsActivity {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/Rapid-DemoApp/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
Sudoku class povides a static main method allowing it to be called
28 | * from the command line to print the solution to a specified Sudoku problem.
29 | *
30 | * 31 | * The following is an example of a Sudoku problem: 32 | * 33 | *
34 | * ----------------------- 35 | * | 8 | 4 2 | 6 | 36 | * | 3 4 | | 9 1 | 37 | * | 9 6 | | 8 4 | 38 | * ----------------------- 39 | * | | 2 1 6 | | 40 | * | | | | 41 | * | | 3 5 7 | | 42 | * ----------------------- 43 | * | 8 4 | | 7 5 | 44 | * | 2 6 | | 1 3 | 45 | * | 9 | 7 1 | 4 | 46 | * ----------------------- 47 | *48 | * 49 | * The goal is to fill in the missing numbers so that every row, column and box contains each of the 50 | * numbers
1-9. Here is the solution to the problem above:
51 | *
52 | * 53 | * ----------------------- 54 | * | 1 8 7 | 4 9 2 | 5 6 3 | 55 | * | 5 3 4 | 6 7 8 | 9 1 2 | 56 | * | 9 6 2 | 1 3 5 | 7 8 4 | 57 | * ----------------------- 58 | * | 4 5 8 | 2 1 6 | 3 9 7 | 59 | * | 2 7 3 | 8 4 9 | 6 5 1 | 60 | * | 6 1 9 | 3 5 7 | 4 2 8 | 61 | * ----------------------- 62 | * | 8 4 1 | 9 6 3 | 2 7 5 | 63 | * | 7 2 6 | 5 8 4 | 1 3 9 | 64 | * | 3 9 5 | 7 2 1 | 8 4 6 | 65 | * ----------------------- 66 | *67 | * 68 | * Note that the first row
187492563 contains each number exactly once, as does the
69 | * first column 159426873, the upper-left box 187534962, and every other
70 | * row, column and box.
71 | *
72 | * 73 | * The {@link #main(String[])} method encodes a problem as an array of strings, with one string 74 | * encoding each constraint in the problem in row-column-value format. Here is the problem again 75 | * with the indices indicated: 76 | * 77 | *
78 | * 0 1 2 3 4 5 6 7 8 79 | * ----------------------- 80 | * 0 | 8 | 4 2 | 6 | 81 | * 1 | 3 4 | | 9 1 | 82 | * 2 | 9 6 | | 8 4 | 83 | * ----------------------- 84 | * 3 | | 2 1 6 | | 85 | * 4 | | | | 86 | * 5 | | 3 5 7 | | 87 | * ----------------------- 88 | * 6 | 8 4 | | 7 5 | 89 | * 7 | 2 6 | | 1 3 | 90 | * 8 | 9 | 7 1 | 4 | 91 | * ----------------------- 92 | *93 | * 94 | * The
8 in the upper left box of the puzzle is encoded as 018 (
95 | * 0 for the row, 1 for the column, and 8 for the value). The
96 | * 4 in the lower right box is encoded as 874.
97 | *
98 | * 99 | * The full command-line invocation for the above puzzle is: 100 | * 101 | *
102 | * % java -cp . Sudoku 018 034 052 076 \ 103 | * 104 | * 113 124 169 171 \ 105 | * 106 | * 209 216 278 284 \ 107 | * 108 | * 332 341 356 \ 109 | * 110 | * 533 545 557 \ 111 | * 112 | * 608 614 677 685 \ 113 | * 114 | * 712 726 761 773 \ 115 | * 116 | * 819 837 851 874 \ 117 | * 118 | *119 | * 120 | *
121 | * See Wikipedia: Sudoku for more information on 122 | * Sudoku. 123 | * 124 | *
125 | * The algorithm employed is similar to the standard backtracking
126 | * eight queens algorithm.
127 | *
128 | * @version 1.0
129 | * @author Bob Carpenter
130 | */
131 | public class Sudoku extends Remoteable {
132 |
133 | private static final long serialVersionUID = -3962977915411306215L;
134 |
135 | private transient DFE dfe;
136 |
137 | private int[][] matrix;
138 |
139 | private String[] input =
140 | {"006", "073", "102", "131", "149", "217", "235", "303", "345", "361", "378", "422", "465",
141 | "514", "521", "548", "582", "658", "679", "743", "752", "784", "818", "883"};
142 |
143 | public Sudoku(DFE dfe) {
144 | this.dfe = dfe;
145 | matrix = parseProblem(input);
146 | }
147 |
148 | @Remote
149 | public boolean localhasSolution() {
150 | return solve(0, 0, matrix);
151 | }
152 |
153 | public boolean solve(int i, int j, int[][] cells) {
154 | if (i == 9) {
155 | i = 0;
156 | if (++j == 9)
157 | return true;
158 | }
159 | if (cells[i][j] != 0)
160 | return solve(i + 1, j, cells);
161 | for (int val = 1; val <= 9; ++val) {
162 | if (legal(i, j, val, cells)) {
163 | cells[i][j] = val;
164 | if (solve(i + 1, j, cells))
165 | return true;
166 | }
167 | }
168 | cells[i][j] = 0;
169 | return false;
170 | }
171 |
172 | private boolean legal(int i, int j, int val, int[][] cells) {
173 | for (int k = 0; k < 9; ++k)
174 | if (val == cells[k][j])
175 | return false;
176 | for (int k = 0; k < 9; ++k)
177 | if (val == cells[i][k])
178 | return false;
179 | int boxRowOffset = (i / 3) * 3;
180 | int boxColOffset = (j / 3) * 3;
181 | for (int k = 0; k < 3; ++k)
182 | for (int m = 0; m < 3; ++m)
183 | if (val == cells[boxRowOffset + k][boxColOffset + m])
184 | return false;
185 | return true;
186 | }
187 |
188 | static int[][] parseProblem(String[] input) {
189 | int[][] problem = new int[9][9];
190 | for (int n = 0; n < input.length; ++n) {
191 | int i = Integer.parseInt(input[n].substring(0, 1));
192 | int j = Integer.parseInt(input[n].substring(1, 2));
193 | int val = Integer.parseInt(input[n].substring(2, 3));
194 | problem[i][j] = val;
195 | }
196 | return problem;
197 | }
198 |
199 | @Override
200 | public void copyState(Remoteable state) {}
201 |
202 | public boolean hasSolution() {
203 | Method toExecute;
204 | Class>[] paramTypes = null;
205 | Object[] paramValues = null;
206 | boolean result = false;
207 | try {
208 | toExecute = this.getClass().getDeclaredMethod("localhasSolution", paramTypes);
209 | result = (Boolean) dfe.execute(toExecute, paramValues, this);
210 | } catch (SecurityException e) {
211 | // Should never get here
212 | e.printStackTrace();
213 | throw e;
214 | } catch (NoSuchMethodException e) {
215 | // Should never get here
216 | e.printStackTrace();
217 | } catch (Throwable e) {
218 | // TODO Auto-generated catch block
219 | e.printStackTrace();
220 | }
221 | return result;
222 | }
223 | }
224 |
--------------------------------------------------------------------------------
/AccelerationClient/src/eu/project/rapid/gvirtusfe/CudaDr_device.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties. To change this
3 | * template file, choose Tools | Templates and open the template in the editor.
4 | */
5 | package eu.project.rapid.gvirtusfe;
6 |
7 | import java.io.IOException;
8 |
9 | /**
10 | *
11 | * @author cferraro
12 | */
13 | public class CudaDr_device {
14 |
15 | public CudaDr_device() {}
16 |
17 | public int cuDeviceGet(Frontend fe, Result res, int devID) throws IOException {
18 |
19 | Buffer b = new Buffer();
20 | b.AddPointer(0);
21 | b.AddInt(devID);
22 | String outputbuffer = "";
23 | StringBuilder output = new StringBuilder();
24 | fe.Execute("cuDeviceGet", b, res);
25 | int sizeType = res.getInput_stream().readByte();
26 | for (int i = 0; i < 7; i++)
27 | res.getInput_stream().readByte();
28 | for (int i = 0; i < sizeType; i++) {
29 | if (i == 0 || i == 1) {
30 | byte bb = res.getInput_stream().readByte();
31 | outputbuffer += Integer.toHexString(bb & 0xFF);
32 | } else
33 | res.getInput_stream().readByte();
34 | }
35 | StringBuilder out2 = new StringBuilder();
36 | if (outputbuffer.length() > 2) {
37 | for (int i = 0; i < outputbuffer.length() - 1; i += 2) {
38 | String str = outputbuffer.substring(i, i + 2);
39 | out2.insert(0, str);
40 | }
41 | outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16));
42 | }
43 | return Integer.valueOf(outputbuffer);
44 |
45 | }
46 |
47 |
48 | public String cuDeviceGetName(Frontend fe, Result res, int len, int dev) throws IOException {
49 |
50 | Buffer b = new Buffer();
51 | b.AddByte(1);
52 | for (int i = 0; i < 8; i++)
53 | b.AddByte(0);
54 | b.AddByte(1);
55 | for (int i = 0; i < 7; i++)
56 | b.AddByte(0);
57 | b.AddInt(len);
58 | b.AddInt(dev);
59 |
60 |
61 | String outbuffer = "";
62 | StringBuilder output = new StringBuilder();
63 | fe.Execute("cuDeviceGetName", b, res);
64 | int sizeType = res.getInput_stream().readByte();
65 |
66 | for (int i = 0; i < 7; i++)
67 | res.getInput_stream().readByte();
68 | res.getInput_stream().readByte();
69 |
70 | for (int i = 0; i < 7; i++)
71 | res.getInput_stream().readByte();
72 |
73 |
74 | for (int i = 0; i < sizeType; i++) {
75 | byte bit = res.getInput_stream().readByte();
76 | outbuffer += Integer.toHexString(bit);
77 | }
78 | for (int i = 0; i < outbuffer.length() - 1; i += 2) {
79 | String str = outbuffer.substring(i, i + 2);
80 | output.append((char) Integer.parseInt(str, 16));
81 |
82 | }
83 | return output.toString();
84 |
85 | }
86 |
87 |
88 | public int cuDeviceGetCount(Frontend fe, Result res) throws IOException {
89 |
90 | Buffer b = new Buffer();
91 | b.AddPointer(0);
92 | String outputbuffer = "";
93 | fe.Execute("cuDeviceGetCount", b, res);
94 | int sizeType = res.getInput_stream().readByte();
95 | for (int i = 0; i < 7; i++)
96 | res.getInput_stream().readByte();
97 | for (int i = 0; i < sizeType; i++) {
98 | if (i == 0) {
99 | byte bb = res.getInput_stream().readByte();
100 | outputbuffer += Integer.toHexString(bb & 0xFF);
101 | } else
102 | res.getInput_stream().readByte();
103 | }
104 | StringBuilder out2 = new StringBuilder();
105 | if (outputbuffer.length() > 2) {
106 | for (int i = 0; i < outputbuffer.length() - 1; i += 2) {
107 | String str = outputbuffer.substring(i, i + 2);
108 | out2.insert(0, str);
109 | }
110 | outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16));
111 | }
112 |
113 | return Integer.valueOf(outputbuffer);
114 |
115 | }
116 |
117 | public int[] cuDeviceComputeCapability(Frontend fe, Result res, int device) throws IOException {
118 |
119 | Buffer b = new Buffer();
120 | b.AddPointer(0);
121 | b.AddPointer(0);
122 | b.AddInt(device);
123 | String outputbuffer = "";
124 | fe.Execute("cuDeviceComputeCapability", b, res);
125 | int sizeType = res.getInput_stream().readByte();
126 | for (int i = 0; i < 7; i++)
127 | res.getInput_stream().readByte();
128 | for (int i = 0; i < sizeType; i++) {
129 | if (i == 0) {
130 | byte bb = res.getInput_stream().readByte();
131 | outputbuffer += Integer.toHexString(bb & 0xFF);
132 | } else
133 | res.getInput_stream().readByte();
134 | }
135 | StringBuilder out2 = new StringBuilder();
136 | if (outputbuffer.length() > 2) {
137 | for (int i = 0; i < outputbuffer.length() - 1; i += 2) {
138 | String str = outputbuffer.substring(i, i + 2);
139 | out2.insert(0, str);
140 | }
141 | outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16));
142 | }
143 |
144 | int[] majorminor = new int[2];
145 |
146 | majorminor[0] = Integer.valueOf(outputbuffer);
147 | outputbuffer = "";
148 | sizeType = res.getInput_stream().readByte();
149 | for (int i = 0; i < 7; i++)
150 | res.getInput_stream().readByte();
151 | for (int i = 0; i < sizeType; i++) {
152 | if (i == 0) {
153 | byte bb = res.getInput_stream().readByte();
154 | outputbuffer += Integer.toHexString(bb & 0xFF);
155 | } else
156 | res.getInput_stream().readByte();
157 | }
158 | StringBuilder out3 = new StringBuilder();
159 | if (outputbuffer.length() > 2) {
160 | for (int i = 0; i < outputbuffer.length() - 1; i += 2) {
161 | String str = outputbuffer.substring(i, i + 2);
162 | out3.insert(0, str);
163 | }
164 | outputbuffer = String.valueOf(Integer.parseInt(out3.toString(), 16));
165 | }
166 | majorminor[1] = Integer.valueOf(outputbuffer);
167 | return majorminor;
168 |
169 | }
170 |
171 | public int cuDeviceGetAttribute(Frontend fe, Result res, int attribute, int device)
172 | throws IOException {
173 | Buffer b = new Buffer();
174 | b.AddPointer(0);
175 | b.AddInt(attribute);
176 | b.AddInt(device);
177 | String outputbuffer = "";
178 | fe.Execute("cuDeviceGetAttribute", b, res);
179 | int sizeType = res.getInput_stream().readByte();
180 | for (int i = 0; i < 7; i++)
181 | res.getInput_stream().readByte();
182 | for (int i = 0; i < sizeType; i++) {
183 | if (i == 0) {
184 | byte bb = res.getInput_stream().readByte();
185 | outputbuffer += Integer.toHexString(bb & 0xFF);
186 | } else
187 | res.getInput_stream().readByte();
188 | }
189 | StringBuilder out2 = new StringBuilder();
190 | if (outputbuffer.length() > 2) {
191 | for (int i = 0; i < outputbuffer.length() - 1; i += 2) {
192 | String str = outputbuffer.substring(i, i + 2);
193 | out2.insert(0, str);
194 | }
195 | outputbuffer = String.valueOf(Integer.parseInt(out2.toString(), 16));
196 | }
197 |
198 | return Integer.valueOf(outputbuffer);
199 |
200 | }
201 |
202 | public long cuDeviceTotalMem(Frontend fe, Result res, int dev) throws IOException {
203 |
204 | Buffer b = new Buffer();
205 | b.AddByte(8);
206 | for (int i = 0; i < 16; i++)
207 | b.AddByte(0);
208 | b.AddInt(dev);
209 | fe.Execute("cuDeviceTotalMem", b, res);
210 | for (int i = 0; i < 8; i++)
211 | res.getInput_stream().readByte();
212 | long x = getLong(res);
213 | return x;
214 |
215 | }
216 |
217 | private long getLong(Result res) throws IOException {
218 |
219 | StringBuilder output = new StringBuilder();
220 | for (int i = 0; i < 8; i++) {
221 | byte bit = res.getInput_stream().readByte();
222 | int a = bit & 0xFF;
223 | if (a == 0) {
224 | output.insert(0, Integer.toHexString(a));
225 | output.insert(0, Integer.toHexString(a));
226 | } else {
227 | output.insert(0, Integer.toHexString(a));
228 | }
229 | }
230 | return Long.parseLong(output.toString(), 16);
231 | }
232 | }
233 |
--------------------------------------------------------------------------------
/Rapid-DemoApp/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |