Skip to content

Fixes for CLBLAST compile support in FreeBSD #2331

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

Merged
merged 2 commits into from
Jul 23, 2023

Conversation

yukiteruamano
Copy link
Contributor

Hi, this PR has two fixes:

  1. New bits in Makefile for add CLBLAST support in FreeBSD.
  2. Instructions for compile llama.cpp in FreeBSD using gmake. These instructions have the packages necessary for OpenBLAS and CLBLAST support for llama.cpp. These packages are available and up-to-date from FreeBSD 11 to FreeBSD 13 in almost architectures supported (only aarch64 remain with lagged support).

All tested in FreeBSD 13.2, local compilation and testing without issues.

@cebtenzzre
Copy link
Collaborator

Why don't we just use pkg-config --cflags clblast OpenCL and pkg-config --libs clblast OpenCL on *BSD and Linux? Some of this special-casing seems unnecessary to me.

@yukiteruamano
Copy link
Contributor Author

Why don't we just use pkg-config --cflags clblast OpenCL and pkg-config --libs clblast OpenCL on *BSD and Linux? Some of this special-casing seems unnecessary to me.

This is possible, the diff code is


diff --git a/Makefile b/Makefile
index 4782096..e620835 100644
--- a/Makefile
+++ b/Makefile
@@ -236,20 +236,14 @@ endif # LLAMA_CUBLAS

 ifdef LLAMA_CLBLAST

-       # If FreeBSD system is detected and env GGML_USE_CLBLAST=1 is used, we compile llama.cpp with this support
-       ifeq ($(UNAME_S),FreeBSD)
-               CFLAGS   += -DGGML_USE_CLBLAST $(shell pkg-config --cflags clblast)
-               CXXFLAGS += -DGGML_USE_CLBLAST $(shell pkg-config --cflags clblast)
-       else
-               CFLAGS   += -DGGML_USE_CLBLAST
-               CXXFLAGS += -DGGML_USE_CLBLAST
-       endif
+       CFLAGS   += -DGGML_USE_CLBLAST $(shell pkg-config --cflags clblast OpenCL)
+       CXXFLAGS += -DGGML_USE_CLBLAST $(shell pkg-config --cflags clblast OpenCL)

        # Mac provides OpenCL as a framework
        ifeq ($(UNAME_S),Darwin)
                LDFLAGS += -lclblast -framework OpenCL
        else
-               LDFLAGS += -lclblast -lOpenCL
+               LDFLAGS += $(shell pkg-config --libs clblast OpenCL)
        endif
        OBJS    += ggml-opencl.o

@ggerganov ggerganov merged commit 91171b8 into ggml-org:master Jul 23, 2023
@yukiteruamano yukiteruamano deleted the fix-clblast-freebsd branch July 23, 2023 18:21
0cc4m added a commit to 0cc4m/koboldcpp that referenced this pull request Jul 24, 2023
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.

3 participants