Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common : try to fix Android CI #6780

Merged
merged 2 commits into from
Apr 20, 2024
Merged

common : try to fix Android CI #6780

merged 2 commits into from
Apr 20, 2024

Conversation

ggerganov
Copy link
Owner

phymbert
phymbert previously approved these changes Apr 20, 2024
@phymbert phymbert dismissed their stale review April 20, 2024 09:00

does not pass :/

@phymbert
Copy link
Collaborator

phymbert commented Apr 20, 2024

@ggerganov What about simply skipping __ANDROID__ definition ?

pthread_setaffinity_np is not supported on android ndk.

patch example
Index: common/common.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/common/common.cpp b/common/common.cpp
--- a/common/common.cpp	(revision 0e4802b2ecbaab04b4f829fde4a3096ca19c84b5)
+++ b/common/common.cpp	(date 1713342380677)
@@ -109,6 +109,7 @@
 }
 
 #if defined(__x86_64__) && defined(__linux__)
+#ifndef __ANDROID__
 #include <pthread.h>
 
 static void cpuid(unsigned leaf, unsigned subleaf,
@@ -156,6 +157,7 @@
     return result;
 }
 
+#endif // __ANDROID__
 #endif // __x86_64__ && __linux__
 
 /**
@@ -163,6 +165,7 @@
  */
 int get_math_cpu_count() {
 #if defined(__x86_64__) && defined(__linux__)
+#ifndef __ANDROID__
     int cpu_count = sysconf(_SC_NPROCESSORS_ONLN);
     if (cpu_count < 1) {
         return get_num_physical_cores();
@@ -177,7 +180,8 @@
             }
         }
     }
-#endif
+#endif // __ANDROID__
+#endif // __x86_64__ && __linux__
     return get_num_physical_cores();
 }
 
Index: examples/llama.android/README.md
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/examples/llama.android/README.md b/examples/llama.android/README.md
--- a/examples/llama.android/README.md	(revision 0e4802b2ecbaab04b4f829fde4a3096ca19c84b5)
+++ b/examples/llama.android/README.md	(date 1713605825665)
@@ -1,0 +1,3 @@
+# llama.cpp/examples/llama.android
+
+Demonstration of simple android app example.

Works for me locally.

BTW I will have a look to the android example. It does not work.

@ggerganov
Copy link
Owner Author

Thanks. I keep forgetting that the Android CI pulls from master, so maybe even the first attempt was correct:

diff --git a/common/common.cpp b/common/common.cpp
index b6143e41..3039e470 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -108,7 +108,7 @@ int32_t get_num_physical_cores() {
     return n_threads > 0 ? (n_threads <= 4 ? n_threads : n_threads / 2) : 4;
 }
 
-#if defined(__x86_64__) && defined(__linux__) && !defined(__ANDROID__)
+#if defined(__x86_64__) && defined(__gnu_linux__)
 #include <pthread.h>
 
 static void cpuid(unsigned leaf, unsigned subleaf,
@@ -162,7 +162,7 @@ static int count_math_cpus(int cpu_count) {
  * Returns number of CPUs on system that are useful for math.
  */
 int get_math_cpu_count() {
-#if defined(__x86_64__) && defined(__linux__) && !defined(__ANDROID__)
+#if defined(__x86_64__) && defined(__gnu_linux__)
     int cpu_count = sysconf(_SC_NPROCESSORS_ONLN);
     if (cpu_count < 1) {
         return get_num_physical_cores();

For now, will merge as it is to make the CI green and can improve in the future

@ggerganov ggerganov merged commit aed82f6 into master Apr 20, 2024
56 of 57 checks passed
@ggerganov ggerganov deleted the gg/android-affinity branch April 20, 2024 10:27
@phymbert
Copy link
Collaborator

phymbert commented Apr 20, 2024

Noted, I will fix that also. At the moment it is impossible to load a model anyway. I will have fun with that :)

@phymbert
Copy link
Collaborator

phymbert commented Apr 20, 2024

okuvshynov pushed a commit to okuvshynov/llama.cpp that referenced this pull request Apr 22, 2024
* common : disable get_math_cpu_count() until Android CI gets fixed

* common : another try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants