Skip to content

Commit d4b22d3

Browse files
committed
Working patches with latest branch and z/OS specific formatting for patches
1 parent fa97aad commit d4b22d3

File tree

13 files changed

+85
-72
lines changed

13 files changed

+85
-72
lines changed

buildenv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ export ZOPEN_DEV_TAG="master"
77
export ZOPEN_NAME="llamacpp-master"
88
export ZOPEN_RUNTIME_DEPS="ncurses"
99

10-
# rm -f "llama"
11-
# ln -s "llama.cpp" "llama"
12-
# ln -s "llama.cpp" $ZOPEN_NAME
10+
rm -f "llama"
11+
ln -s "llama.cpp" "llama"
12+
ln -s "llama.cpp" $ZOPEN_NAME
1313

1414
export ZOPEN_COMP="CLANG"
1515
# set env variables
1616
# export CURL_HOME="/data/zopen/usr/local/zopen/curl/curl"
17-
# export BLAS_HOME="/usr/lpp/cbclib"
17+
export BLAS_HOME="/usr/lpp/cbclib"
1818

1919
export ZOPEN_CONFIGURE="cmake"
2020
export ZOPEN_CONFIGURE_OPTS="-B ../build --install-prefix \"\$ZOPEN_INSTALL_DIR/\" -DCURL_LIBRARY=\$CURL_HOME/lib/libcurl.a -DCURL_INCLUDE_DIR=\$CURL_HOME/include -DBUILD_SHARED_LIBS_DEFAULT=OFF -DBUILD_SHARED_LIBS=OFF -DGGML_STATIC=ON -DGGML_BACKEND_DL=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS=\$BLAS_HOME/include/openblas -DBLAS_LIBRARIES=\$BLAS_HOME/lib/libopenblas.so -DLLAMA_BUILD_TESTS=ON ."
@@ -76,4 +76,4 @@ zopen_get_version()
7676
# Modify to echo the version of your tool/library
7777
# Rather than hardcoding the version, obtain the version by running the tool/library
7878
echo "1.0.0"
79-
}
79+
}

examples/frontend/src/components/ChatMode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const ChatMode = ({ conversationStarted, setConversationStarted }) => {
139139
onClick={handleChatSubmit}
140140
disabled={isTyping}
141141
>
142-
➤
142+
➤
143143
</button>
144144
</div>
145145
</div>

patches/arg.cpp.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ index 40af7e57..46fec792 100644
1010
+# include <cstdlib>
1111
+# endif
1212
#endif
13-
13+
1414
using json = nlohmann::ordered_json;
1515
@@ -195,6 +198,8 @@ bool common_has_curl() {
1616
# endif

patches/ggml-backend-reg.cpp.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ index 405d8e3..b3682a9 100644
44
+++ b/ggml/src/ggml-backend-reg.cpp
55
@@ -556,7 +556,9 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
66
}
7-
7+
88
void ggml_backend_load_all() {
99
- ggml_backend_load_all_from_path(nullptr);
1010
+#ifdef GGML_BACKEND_DL
1111
+ ggml_backend_load_all_from_path(nullptr);
1212
+#endif
1313
}
14-
14+
1515
void ggml_backend_load_all_from_path(const char * dir_path) {

patches/ggml-cpu.c.patch

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ index c7426df..e074799 100644
33
--- a/ggml/src/ggml-cpu/ggml-cpu.c
44
+++ b/ggml/src/ggml-cpu/ggml-cpu.c
55
@@ -17,7 +17,7 @@
6-
6+
77
#if defined(_MSC_VER) || defined(__MINGW32__)
88
#include <malloc.h> // using malloc.h with MSC/MINGW
99
-#elif !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
1010
+#elif !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__MVS__)
1111
#include <alloca.h>
1212
#endif
13+

patches/ggml-cpu.cpp.patch

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ index e013e8b..6290b22 100644
55
@@ -33,6 +33,38 @@
66
# include <sys/types.h>
77
#endif
8-
9-
+#define CVT_PTR 0x10
10-
+#define CVTRCEP_OFFSET 0x490
11-
+#define RCEAFC_OFFSET 0x088
8+
9+
+#define CVT_PTR 0x10
10+
+#define CVTRCEP_OFFSET 0x490
11+
+#define RCEAFC_OFFSET 0x088
1212
+
1313
+typedef unsigned data_area_ptr_assign_type;
1414
+
@@ -17,7 +17,7 @@ index e013e8b..6290b22 100644
1717
+#if defined(_LP64)
1818
+ data_area_ptr_assign_type lower;
1919
+#endif
20-
+ data_area_ptr_assign_type assign;
20+
+ data_area_ptr_assign_type assign;
2121
+ };
2222
+ char* deref;
2323
+} data_area_ptr;
@@ -39,15 +39,15 @@ index e013e8b..6290b22 100644
3939
+}
4040
+
4141
// ggml-backend interface
42-
42+
4343
std::vector<ggml_backend_buffer_type_t>& ggml_backend_cpu_get_extra_buffers_type() {
4444
@@ -43,7 +75,7 @@ std::vector<ggml_backend_buffer_type_t>& ggml_backend_cpu_get_extra_buffers_type
4545
if (ggml_backend_amx_buffer_type()) {
4646
bufts.push_back(ggml_backend_amx_buffer_type());
4747
}
4848
-#endif
49-
+#endif
50-
49+
+#endif
50+
5151
#ifdef GGML_USE_CPU_KLEIDIAI
5252
if (ggml_backend_cpu_kleidiai_buffer_type()) {
5353
@@ -340,6 +372,9 @@ static void ggml_backend_cpu_device_get_memory(ggml_backend_dev_t dev, size_t *
@@ -59,4 +59,4 @@ index e013e8b..6290b22 100644
5959
+ *free = get_free_memory();
6060
#else
6161
long pages = sysconf(_SC_PHYS_PAGES);
62-
long page_size = sysconf(_SC_PAGE_SIZE);
62+
long page_size = sysconf(_SC_PAGE_SIZE);

patches/ggml.c.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ index 97da26b3..212faf9c 100644
55
@@ -14,9 +14,13 @@
66
#include <hbwmalloc.h>
77
#endif
8-
8+
99
+#if defined(__MVS__)
1010
+#include <zos-base.h>
1111
+#endif
@@ -16,19 +16,19 @@ index 97da26b3..212faf9c 100644
1616
+#elif !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__MVS__)
1717
#include <alloca.h>
1818
#endif
19-
19+
2020
@@ -299,6 +303,15 @@ void * ggml_aligned_malloc(size_t size) {
21-
21+
2222
#if defined(_MSC_VER) || defined(__MINGW32__)
2323
return _aligned_malloc(size, alignment);
2424
+#elif defined(__MVS__)
2525
+// void * aligned_memory = NULL;
2626
+// if (size ==0)
27-
+// size = 1;
27+
+// size = 1;
2828
+// aligned_memory = malloc(size);
2929
+// int result = 0;
3030
+// if (aligned_memory == NULL)
31-
+// result = errno;
31+
+// result = errno;
3232
+ return __aligned_malloc(size, alignment);
3333
#else
3434
if (size == 0) {
@@ -41,4 +41,4 @@ index 97da26b3..212faf9c 100644
4141
+ __aligned_free(ptr);
4242
#elif GGML_USE_CPU_HBM
4343
if (ptr != NULL) {
44-
hbw_free(ptr);
44+
hbw_free(ptr);

patches/llama-context.cpp.patch

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@ index 06e93b19..0db8530f 100644
77
}
88
}
99
-
10-
+
10+
+
1111
+ #ifndef __MVS__
1212
std::fill(output_ids.begin(), output_ids.end(), -1);
1313
-
14-
+ #else
15-
+ for (auto& id: output_ids) {
16-
+ id = -1;
17-
+ }
14+
+ #else
15+
+ for (auto& id: output_ids) {
16+
+ id = -1;
17+
+ }
1818
for (uint32_t i = 0; i < n_outputs; ++i) {
1919
output_ids[out_ids[i]] = i;
2020
}
21-
+ #endif
21+
+ #endif
2222
}
2323
}
24-
24+
2525
@@ -1264,8 +1269,10 @@ uint32_t llama_context::output_reserve(int32_t n_outputs) {
2626
embd = has_embd ? output_base + logits_size : nullptr;
27-
27+
2828
// set all ids as invalid (negative)
2929
- std::fill(output_ids.begin(), output_ids.end(), -1);
3030
-
3131
+ //std::fill(output_ids.begin(), output_ids.end(), -1);
3232
+ for (auto& id: output_ids) {
33-
+ id = -1;
33+
+ id = -1;
3434
+ }
3535
this->n_outputs = 0;
36-
37-
return n_outputs_max;
36+
37+
return n_outputs_max;

patches/llama-hparams.h.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/src/llama-hparams.h b/src/llama-hparams.h
2+
index 8b7e2a11..530dfea2 100644
3+
--- a/src/llama-hparams.h
4+
+++ b/src/llama-hparams.h
5+
@@ -3,6 +3,7 @@
6+
#include "llama.h"
7+
8+
#include <array>
9+
+#include <algorithm>
10+
11+
// bump if necessary
12+
#define LLAMA_MAX_LAYERS 512

patches/miniaudio.h.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ index c74bebe..72cbafd 100644
44
+++ b/vendor/miniaudio/miniaudio.h
55
@@ -3873,8 +3873,8 @@ typedef ma_uint16 wchar_t;
66
#define MA_POSIX
7-
7+
88
/*
99
- Use the MA_NO_PTHREAD_IN_HEADER option at your own risk. This is intentionally undocumented.
1010
- You can use this to avoid including pthread.h in the header section. The downside is that it
@@ -16,9 +16,9 @@ index c74bebe..72cbafd 100644
1616
@@ -16176,7 +16176,7 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority
1717
int result;
1818
pthread_attr_t* pAttr = NULL;
19-
19+
2020
-#if !defined(__EMSCRIPTEN__) && !defined(__3DS__)
2121
+#if !defined(__EMSCRIPTEN__) && !defined(__3DS__) && !defined(__MVS__)
2222
/* Try setting the thread priority. It's not critical if anything fails here. */
2323
pthread_attr_t attr;
24-
if (pthread_attr_init(&attr) == 0) {
24+
if (pthread_attr_init(&attr) == 0) {

0 commit comments

Comments
 (0)