Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions cmd/gorse-in-one/Dockerfile.mkl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
############################
# STEP 1 build executable binary
############################
FROM debian:bookworm
FROM golang:1.25-bookworm

# Install Intel® oneAPI Toolkits

Expand All @@ -16,12 +16,6 @@ RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https:/

RUN apt update && apt install -y intel-oneapi-base-toolkit

# Install Go

COPY --from=golang:1.25 /usr/local/go/ /usr/local/go/

ENV PATH /usr/local/go/bin:$PATH

# Build Gorse

WORKDIR /src
Expand Down
63 changes: 63 additions & 0 deletions cmd/gorse-in-one/Dockerfile.openblas
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# syntax = docker/dockerfile:1

############################
# STEP 1 build executable binary
############################
FROM --platform=$BUILDPLATFORM golang:1.25

# Install OpenBLAS

ARG BUILDARCH

ARG TARGETARCH

RUN if [ "${TARGETARCH}" = "amd64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-x86-64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-aarch64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
elif [ "${TARGETARCH}" = "riscv64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-riscv64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
else \
echo "Unsupported TARGETARCH ${TARGETARCH}"; exit 1; \
fi

# Build Gorse

WORKDIR /src

COPY go.* ./

RUN go mod download

COPY . ./

ARG TARGETOS

RUN --mount=type=cache,target=/root/.cache/go-build \
if [ "${TARGETARCH}" = "amd64" ]; then \
export CC=x86_64-linux-gnu-gcc; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
export CC=aarch64-linux-gnu-gcc; \
elif [ "${TARGETARCH}" = "riscv64" ]; then \
export CC=riscv64-linux-gnu-gcc; \
else \
echo "Unsupported TARGETARCH ${TARGETARCH}"; exit 1; \
fi && \
cd cmd/gorse-in-one && \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=1 go build -tags openblas -ldflags=" \
-X 'github.com/gorse-io/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \
-X 'github.com/gorse-io/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \
-X 'github.com/gorse-io/gorse/cmd/version.BuildTime=$(date)'" .

############################
# STEP 2 build runtime image
############################
FROM debian:trixie-slim

COPY --from=0 /src/cmd/gorse-in-one/gorse-in-one /usr/bin/gorse-in-one

RUN /usr/bin/gorse-in-one --version

ENV USER root

ENTRYPOINT ["/usr/bin/gorse-in-one", "-c", "/etc/gorse/config.toml"]
8 changes: 1 addition & 7 deletions cmd/gorse-master/Dockerfile.mkl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
############################
# STEP 1 build executable binary
############################
FROM debian:bookworm
FROM golang:1.25-bookworm

# Install Intel® oneAPI Toolkits

Expand All @@ -16,12 +16,6 @@ RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https:/

RUN apt update && apt install -y intel-oneapi-base-toolkit

# Install Go

COPY --from=golang:1.25 /usr/local/go/ /usr/local/go/

ENV PATH /usr/local/go/bin:$PATH

# Build Gorse

WORKDIR /src
Expand Down
63 changes: 63 additions & 0 deletions cmd/gorse-master/Dockerfile.openblas
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# syntax = docker/dockerfile:1

############################
# STEP 1 build executable binary
############################
FROM --platform=$BUILDPLATFORM golang:1.25

# Install OpenBLAS

ARG BUILDARCH

ARG TARGETARCH

RUN if [ "${TARGETARCH}" = "amd64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-x86-64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-aarch64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
elif [ "${TARGETARCH}" = "riscv64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-riscv64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
else \
echo "Unsupported TARGETARCH ${TARGETARCH}"; exit 1; \
fi

# Build Gorse

WORKDIR /src

COPY go.* ./

RUN go mod download

COPY . ./

ARG TARGETOS

RUN --mount=type=cache,target=/root/.cache/go-build \
if [ "${TARGETARCH}" = "amd64" ]; then \
export CC=x86_64-linux-gnu-gcc; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
export CC=aarch64-linux-gnu-gcc; \
elif [ "${TARGETARCH}" = "riscv64" ]; then \
export CC=riscv64-linux-gnu-gcc; \
else \
echo "Unsupported TARGETARCH ${TARGETARCH}"; exit 1; \
fi && \
cd cmd/gorse-master && \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=1 go build -tags openblas -ldflags=" \
-X 'github.com/gorse-io/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \
-X 'github.com/gorse-io/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \
-X 'github.com/gorse-io/gorse/cmd/version.BuildTime=$(date)'" .

############################
# STEP 2 build runtime image
############################
FROM debian:trixie-slim

COPY --from=0 /src/cmd/gorse-master/gorse-master /usr/bin/gorse-master

RUN /usr/bin/gorse-master --version

ENV USER root

ENTRYPOINT ["/usr/bin/gorse-master", "-c", "/etc/gorse/config.toml"]
8 changes: 1 addition & 7 deletions cmd/gorse-server/Dockerfile.mkl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
############################
# STEP 1 build executable binary
############################
FROM debian:bookworm
FROM golang:1.25-bookworm

# Install Intel® oneAPI Toolkits

Expand All @@ -16,12 +16,6 @@ RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https:/

RUN apt update && apt install -y intel-oneapi-base-toolkit

# Install Go

COPY --from=golang:1.25 /usr/local/go/ /usr/local/go/

ENV PATH /usr/local/go/bin:$PATH

# Build Gorse

WORKDIR /src
Expand Down
63 changes: 63 additions & 0 deletions cmd/gorse-server/Dockerfile.openblas
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# syntax = docker/dockerfile:1

############################
# STEP 1 build executable binary
############################
FROM --platform=$BUILDPLATFORM golang:1.25

# Install OpenBLAS

ARG BUILDARCH

ARG TARGETARCH

RUN if [ "${TARGETARCH}" = "amd64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-x86-64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-aarch64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
elif [ "${TARGETARCH}" = "riscv64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-riscv64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
else \
echo "Unsupported TARGETARCH ${TARGETARCH}"; exit 1; \
fi

# Build Gorse

WORKDIR /src

COPY go.* ./

RUN go mod download

COPY . ./

ARG TARGETOS

RUN --mount=type=cache,target=/root/.cache/go-build \
if [ "${TARGETARCH}" = "amd64" ]; then \
export CC=x86_64-linux-gnu-gcc; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
export CC=aarch64-linux-gnu-gcc; \
elif [ "${TARGETARCH}" = "riscv64" ]; then \
export CC=riscv64-linux-gnu-gcc; \
else \
echo "Unsupported TARGETARCH ${TARGETARCH}"; exit 1; \
fi && \
cd cmd/gorse-server && \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=1 go build -tags openblas -ldflags=" \
-X 'github.com/gorse-io/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \
-X 'github.com/gorse-io/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \
-X 'github.com/gorse-io/gorse/cmd/version.BuildTime=$(date)'" .

############################
# STEP 2 build runtime image
############################
FROM debian:trixie-slim

COPY --from=0 /src/cmd/gorse-server/gorse-server /usr/bin/gorse-server

RUN /usr/bin/gorse-server --version

ENV USER root

ENTRYPOINT ["/usr/bin/gorse-server"]
8 changes: 1 addition & 7 deletions cmd/gorse-worker/Dockerfile.mkl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
############################
# STEP 1 build executable binary
############################
FROM debian:bookworm
FROM golang:1.25-bookworm

# Install Intel® oneAPI Toolkits

Expand All @@ -16,12 +16,6 @@ RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https:/

RUN apt update && apt install -y intel-oneapi-base-toolkit

# Install Go

COPY --from=golang:1.25 /usr/local/go/ /usr/local/go/

ENV PATH /usr/local/go/bin:$PATH

# Build Gorse

WORKDIR /src
Expand Down
63 changes: 63 additions & 0 deletions cmd/gorse-worker/Dockerfile.openblas
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# syntax = docker/dockerfile:1

############################
# STEP 1 build executable binary
############################
FROM --platform=$BUILDPLATFORM golang:1.25

# Install OpenBLAS

ARG BUILDARCH

ARG TARGETARCH

RUN if [ "${TARGETARCH}" = "amd64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-x86-64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-aarch64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
elif [ "${TARGETARCH}" = "riscv64" ]; then \
dpkg --add-architecture ${TARGETARCH} && apt update && apt install -y gcc-riscv64-linux-gnu libopenblas-dev:${TARGETARCH} git; \
else \
echo "Unsupported TARGETARCH ${TARGETARCH}"; exit 1; \
fi

# Build Gorse

WORKDIR /src

COPY go.* ./

RUN go mod download

COPY . ./

ARG TARGETOS

RUN --mount=type=cache,target=/root/.cache/go-build \
if [ "${TARGETARCH}" = "amd64" ]; then \
export CC=x86_64-linux-gnu-gcc; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
export CC=aarch64-linux-gnu-gcc; \
elif [ "${TARGETARCH}" = "riscv64" ]; then \
export CC=riscv64-linux-gnu-gcc; \
else \
echo "Unsupported TARGETARCH ${TARGETARCH}"; exit 1; \
fi && \
cd cmd/gorse-worker && \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=1 go build -tags openblas -ldflags=" \
-X 'github.com/gorse-io/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \
-X 'github.com/gorse-io/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \
-X 'github.com/gorse-io/gorse/cmd/version.BuildTime=$(date)'" .

############################
# STEP 2 build runtime image
############################
FROM debian:trixie-slim

COPY --from=0 /src/cmd/gorse-worker/gorse-worker /usr/bin/gorse-worker

RUN /usr/bin/gorse-worker --version

ENV USER root

ENTRYPOINT ["/usr/bin/gorse-worker"]
26 changes: 26 additions & 0 deletions common/blas/blas_openblas.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//go:build cgo && openblas

// Copyright 2025 gorse Project Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package blas

// #cgo LDFLAGS: -lopenblas -lm -pthread -static
// #include <cblas.h>
import "C"

func SGEMM(order Order, transA, transB Transpose, m, n, k int, alpha float32, a []float32, lda int, b []float32, ldb int, beta float32, c []float32, ldc int) {
C.cblas_sgemm(uint32(order), uint32(transA), uint32(transB), C.int(m), C.int(n), C.int(k), C.float(alpha),
(*C.float)(&a[0]), C.int(lda), (*C.float)(&b[0]), C.int(ldb), C.float(beta), (*C.float)(&c[0]), C.int(ldc))
}
5 changes: 3 additions & 2 deletions common/floats/floats_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
AVX512F
CUDA
MKL
OPENBLAS
)

const AVX512 = AVX | FMA | AVX512F
Expand Down Expand Up @@ -188,9 +189,9 @@ func (feature Feature) euclidean(a, b []float32) float32 {
func (feature Feature) mm(transA, transB bool, m, n, k int, a []float32, lda int, b []float32, ldb int, c []float32, ldc int) {
// Bypass AVX512 optimizations when CUDA is enabled to avoid potential conflicts
// between CUDA-based and AVX512-based matrix multiplication implementations.
if feature&AVX512 == AVX512 && feature&CUDA == 0 && feature&MKL == 0 {
if feature&AVX512 == AVX512 && feature&CUDA == 0 && feature&MKL == 0 && feature&OPENBLAS == 0 {
_mm512_mm(transA, transB, int64(m), int64(n), int64(k), unsafe.Pointer(&a[0]), int64(lda), unsafe.Pointer(&b[0]), int64(ldb), unsafe.Pointer(&c[0]), int64(ldc))
} else if feature&AVX == AVX && feature&CUDA == 0 && feature&MKL == 0 {
} else if feature&AVX == AVX && feature&CUDA == 0 && feature&MKL == 0 && feature&OPENBLAS == 0 {
_mm256_mm(transA, transB, int64(m), int64(n), int64(k), unsafe.Pointer(&a[0]), int64(lda), unsafe.Pointer(&b[0]), int64(ldb), unsafe.Pointer(&c[0]), int64(ldc))
} else {
mm(transA, transB, m, n, k, a, lda, b, ldb, c, ldc)
Expand Down
Loading
Loading