Skip to content

Commit 7c9ee80

Browse files
author
Daniil Efremov
committed
Add ViennaCL cache support #82
- fix non existed dir issue works fine now ~10x faster after cache generation - displays genrated genrated cache files to app log
1 parent 5976a0a commit 7c9ee80

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

app/src/main/java/openscience/crowdsource/video/experiments/MainActivity.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ protected String doInBackground(String... arg0) {
763763
publishProgress("\nUnfortunately, no scenarios found for your device ...");
764764
return null;
765765
}
766-
766+
String localAppPath = AppConfigService.getLocalAppPath() + File.separator + "openscience" + File.separator;
767767
for (int i = 0; i < scenarios.length(); i++) {
768768
JSONObject scenario = scenarios.getJSONObject(i);
769769
final String module_uoa = scenario.getString("module_uoa");
@@ -845,7 +845,6 @@ public void println(String text) {
845845
// copyToAppSpace is not mandatory
846846
}
847847
if (copyToAppSpace != null && copyToAppSpace.equalsIgnoreCase("yes")) {
848-
String localAppPath = AppConfigService.getLocalAppPath() + File.separator + "openscience" + File.separator;
849848
String fileAppDir = localAppPath + file.getString("path");
850849
File appfp = new File(fileAppDir);
851850
if (!appfp.exists()) {
@@ -937,7 +936,14 @@ public void println(String text) {
937936

938937
if (openCLlibPath != null) {
939938
libPath = libPath + ":" + openCLlibPath;
940-
viennaclCachePath = AppConfigService.getLocalAppPath() + File.separator + "openscience" + File.separator + "viennacl_cache"+ File.separator;
939+
viennaclCachePath = localAppPath + File.separator + "viennacl_cache"+ File.separator;
940+
File appfp = new File(viennaclCachePath);
941+
if (!appfp.exists()) {
942+
if (!appfp.mkdirs()) {
943+
publishProgress("\nError creating dir (" + viennaclCachePath + ") ...");
944+
return null;
945+
}
946+
}
941947

942948
}
943949
String[] scenarioEnv = {
@@ -1021,12 +1027,13 @@ public void run() {
10211027
publishProgress("\nRecognition result:" + recognitionRawResultText);
10221028

10231029

1024-
1025-
String[] lsCacheResult = openme.openme_run_program("ls " + viennaclCachePath, null, viennaclCachePath);
1026-
if (!lsCacheResult [0].isEmpty()) {
1027-
publishProgress(" * ViennaCL cache dir " + lsCacheResult[0]);
1028-
} else {
1029-
publishProgress("ViennaCL cache dir not inited ");
1030+
if (viennaclCachePath != null && !viennaclCachePath.trim().equals("")) {
1031+
String[] lsCacheResult = openme.openme_run_program("ls " + viennaclCachePath, null, viennaclCachePath);
1032+
if (!lsCacheResult [1].isEmpty()) {
1033+
publishProgress("ViennaCL cache generated " + lsCacheResult[1]);
1034+
} else {
1035+
publishProgress("ViennaCL cache not generated");
1036+
}
10301037
}
10311038

10321039

0 commit comments

Comments
 (0)