mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
gpu: add levelzero application
Signed-off-by: Tuomas Katila <tuomas.katila@intel.com>
This commit is contained in:
parent
78f7c959e6
commit
2df9443fda
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -14,6 +14,7 @@
|
||||
/cmd/gpu_fakedev/ @tkatila @uniemimu @eero-t
|
||||
/cmd/gpu_plugin/ @tkatila @bart0sh @uniemimu
|
||||
/cmd/gpu_nfdhook/ @tkatila @bart0sh @uniemimu
|
||||
/cmd/gpu_levelzero/ @tkatila @eero-t @uniemimu
|
||||
/cmd/qat_plugin/ @hj-johannes-lee @mythi
|
||||
/cmd/sgx_plugin/ @hj-johannes-lee @mythi
|
||||
/cmd/dsa_plugin/ @hj-johannes-lee @ozhuraki @mythi
|
||||
|
2
.github/workflows/lib-validate.yaml
vendored
2
.github/workflows/lib-validate.yaml
vendored
@ -58,6 +58,8 @@ jobs:
|
||||
- run: make go-mod-tidy
|
||||
- run: make BUILDTAGS=kerneldrv
|
||||
- run: make test BUILDTAGS=kerneldrv
|
||||
env:
|
||||
UNITTEST: 1
|
||||
- run: make check-github-actions
|
||||
#- name: Codecov report
|
||||
# run: bash <(curl -s https://codecov.io/bash)
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,7 +23,6 @@ cmd/operator/operator
|
||||
|
||||
deployments/fpga_admissionwebhook/base/intel-fpga-webhook-certs-secret
|
||||
|
||||
*.h
|
||||
*.gbs.*
|
||||
*.aocx
|
||||
*.aocx.*
|
||||
|
@ -29,7 +29,12 @@ if [ -d $(dirname $0)/../../vendor ] ; then
|
||||
BUILD_ARGS="${BUILD_ARGS} --build-arg DIR=/go/src/github.com/intel/intel-device-plugins-for-kubernetes --build-arg GO111MODULE=off"
|
||||
fi
|
||||
|
||||
BUILD_ARGS="${BUILD_ARGS} --build-arg FINAL_BASE=gcr.io/distroless/static"
|
||||
BUILD_ARGS="${BUILD_ARGS} \
|
||||
--build-arg FINAL_BASE=gcr.io/distroless/static \
|
||||
--build-arg BUILD_BASE=golang:1.23-bookworm \
|
||||
--build-arg FINAL_BASE_DYN=debian:unstable-slim \
|
||||
--build-arg ROCKYLINUX=0"
|
||||
|
||||
if [ -z "${BUILDER}" -o "${BUILDER}" = 'docker' -o "${BUILDER}" = 'podman' ] ; then
|
||||
${BUILDER} build --pull -t ${IMG}:${TAG} ${BUILD_ARGS} -f ${DOCKERFILE} .
|
||||
elif [ "${BUILDER}" = 'buildah' ] ; then
|
||||
|
91
build/docker/intel-gpu-levelzero.Dockerfile
Normal file
91
build/docker/intel-gpu-levelzero.Dockerfile
Normal file
@ -0,0 +1,91 @@
|
||||
## This is a generated file, do not edit directly. Edit build/docker/templates/intel-gpu-levelzero.Dockerfile.in instead.
|
||||
##
|
||||
## Copyright 2022 Intel Corporation. All Rights Reserved.
|
||||
##
|
||||
## 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.
|
||||
###
|
||||
ARG CMD=gpu_levelzero
|
||||
ARG ROCKYLINUX=1
|
||||
## FINAL_BASE_DYN can be used to configure the base image of the final image.
|
||||
## The project default is 1) which sets FINAL_BASE_DYN=gcr.io/distroless/cc-debian12
|
||||
## (see build-image.sh).
|
||||
## 2) and the default FINAL_BASE is primarily used to build Redhat Certified Openshift Operator container images that must be UBI based.
|
||||
## The RedHat build tool does not allow additional image build parameters.
|
||||
ARG BUILD_BASE=rockylinux:9
|
||||
ARG FINAL_BASE_DYN=registry.access.redhat.com/ubi9/ubi-minimal:9.3
|
||||
###
|
||||
FROM ${BUILD_BASE} as builder
|
||||
ARG DIR=/intel-device-plugins-for-kubernetes
|
||||
ENV CGO_CFLAGS="-pipe -fno-plt"
|
||||
ENV CGO_LDFLAGS="-fstack-protector-strong -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,noexecstack,-z,defs,-s,-w"
|
||||
ENV CGOFLAGS="-trimpath -mod=readonly -buildmode=pie"
|
||||
ENV GCFLAGS="all=-spectre=all -N -l"
|
||||
ENV ASMFLAGS="all=-spectre=all"
|
||||
ENV LDFLAGS="all=-linkmode=external -s -w"
|
||||
ARG GOLICENSES_VERSION
|
||||
ARG CMD
|
||||
ARG ROCKYLINUX
|
||||
ARG CGO_VERSION=1.23
|
||||
RUN mkdir /runtime
|
||||
RUN if [ $ROCKYLINUX -eq 0 ]; then \
|
||||
apt-get update && apt-get install --no-install-recommends -y wget libc6-dev ca-certificates ocl-icd-libopencl1 && \
|
||||
cd /runtime && \
|
||||
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-level-zero-gpu_1.3.30049.6_amd64.deb && \
|
||||
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-opencl-icd_24.26.30049.6_amd64.deb && \
|
||||
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/libigdgmm12_22.3.20_amd64.deb && \
|
||||
wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero-devel_1.17.6+u22.04_amd64.deb && \
|
||||
wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero_1.17.6+u22.04_amd64.deb && \
|
||||
dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && \
|
||||
rm -rf /var/lib/apt/lists/\*; \
|
||||
else \
|
||||
source /etc/os-release && dnf install -y gcc jq wget 'dnf-command(config-manager)' && \
|
||||
dnf config-manager --add-repo https://repositories.intel.com/gpu/rhel/${VERSION_ID}/lts/2350/unified/intel-gpu-${VERSION_ID}.repo && \
|
||||
dnf install -y intel-opencl level-zero level-zero-devel intel-level-zero-gpu intel-gmmlib intel-ocloc && \
|
||||
dnf clean all && \
|
||||
LATEST_GO=$(curl --no-progress-meter https://go.dev/dl/?mode=json | jq ".[] | select(.version | startswith(\"go${CGO_VERSION}\")).version" | tr -d "\"") && \
|
||||
wget -q https://go.dev/dl/$LATEST_GO.linux-amd64.tar.gz -O - | tar -xz -C /usr/local && \
|
||||
cp -a /etc/OpenCL /usr/lib64/libocloc.so /usr/lib64/libze_intel_gpu.* /usr/lib64/libze_loader.* /usr/lib64/libigdgmm.* /runtime/ && \
|
||||
mkdir /runtime/licenses/ && cd /usr/share/licenses/ && cp -a level-zero intel-gmmlib intel-level-zero-gpu intel-ocloc /runtime/licenses/; \
|
||||
fi
|
||||
ARG EP=/usr/local/bin/intel_gpu_levelzero
|
||||
ARG CMD
|
||||
WORKDIR ${DIR}
|
||||
COPY . .
|
||||
RUN export PATH=$PATH:/usr/local/go/bin/ && cd cmd/${CMD} && \
|
||||
GO111MODULE=on CGO_ENABLED=1 go install $CGOFLAGS --gcflags="$GCFLAGS" --asmflags="$ASMFLAGS" --ldflags="$LDFLAGS"
|
||||
RUN [ $ROCKYLINUX -eq 0 ] && install -D /go/bin/${CMD} /install_root${EP} || install -D /root/go/bin/${CMD} /install_root${EP}
|
||||
RUN install -D ${DIR}/LICENSE /install_root/licenses/intel-device-plugins-for-kubernetes/LICENSE \
|
||||
&& if [ ! -d "licenses/$CMD" ] ; then \
|
||||
GO111MODULE=on go run github.com/google/go-licenses@${GOLICENSES_VERSION} save "./cmd/$CMD" \
|
||||
--save_path /install_root/licenses/$CMD/go-licenses ; \
|
||||
else mkdir -p /install_root/licenses/$CMD/go-licenses/ && cd licenses/$CMD && cp -r * /install_root/licenses/$CMD/go-licenses/ ; fi
|
||||
FROM ${FINAL_BASE_DYN}
|
||||
ARG CMD
|
||||
ARG ROCKYLINUX
|
||||
COPY --from=builder /runtime /runtime
|
||||
RUN if [ $ROCKYLINUX -eq 0 ]; then \
|
||||
apt-get update && apt-get install --no-install-recommends -y ocl-icd-libopencl1 && \
|
||||
rm /runtime/level-zero-devel_*.deb && \
|
||||
cd /runtime && dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && rm -rf /runtime && \
|
||||
rm "/lib/x86_64-linux-gnu/libze_validation"* && rm "/lib/x86_64-linux-gnu/libze_tracing_layer"*; \
|
||||
else \
|
||||
cp -a /runtime//*.so* /usr/lib64/ && cp -a /runtime/OpenCL /etc/ && cp -a /runtime/licenses/* /usr/share/licenses/; \
|
||||
fi
|
||||
COPY --from=builder /install_root /
|
||||
ENTRYPOINT ["/usr/local/bin/intel_gpu_levelzero"]
|
||||
LABEL vendor='Intel®'
|
||||
LABEL version='devel'
|
||||
LABEL release='1'
|
||||
LABEL name='intel-gpu-levelzero'
|
||||
LABEL summary='Intel® GPU levelzero for Kubernetes'
|
||||
LABEL description='The GPU levelzero container provides access to Levelzero API for the Intel GPU plugin'
|
87
build/docker/templates/intel-gpu-levelzero.Dockerfile.in
Normal file
87
build/docker/templates/intel-gpu-levelzero.Dockerfile.in
Normal file
@ -0,0 +1,87 @@
|
||||
#define _ENTRYPOINT_ /usr/local/bin/intel_gpu_levelzero
|
||||
|
||||
ARG CMD=gpu_levelzero
|
||||
ARG ROCKYLINUX=1
|
||||
|
||||
## FINAL_BASE_DYN can be used to configure the base image of the final image.
|
||||
## The project default is 1) which sets FINAL_BASE_DYN=gcr.io/distroless/cc-debian12
|
||||
## (see build-image.sh).
|
||||
## 2) and the default FINAL_BASE is primarily used to build Redhat Certified Openshift Operator container images that must be UBI based.
|
||||
## The RedHat build tool does not allow additional image build parameters.
|
||||
ARG BUILD_BASE=rockylinux:9
|
||||
ARG FINAL_BASE_DYN=registry.access.redhat.com/ubi9/ubi-minimal:9.3
|
||||
###
|
||||
|
||||
FROM ${BUILD_BASE} as builder
|
||||
|
||||
ARG DIR=/intel-device-plugins-for-kubernetes
|
||||
|
||||
ENV CGO_CFLAGS="-pipe -fno-plt"
|
||||
ENV CGO_LDFLAGS="-fstack-protector-strong -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,noexecstack,-z,defs,-s,-w"
|
||||
ENV CGOFLAGS="-trimpath -mod=readonly -buildmode=pie"
|
||||
ENV GCFLAGS="all=-spectre=all -N -l"
|
||||
ENV ASMFLAGS="all=-spectre=all"
|
||||
ENV LDFLAGS="all=-linkmode=external -s -w"
|
||||
|
||||
ARG GOLICENSES_VERSION
|
||||
ARG CMD
|
||||
ARG ROCKYLINUX
|
||||
ARG CGO_VERSION=1.23
|
||||
|
||||
RUN mkdir /runtime
|
||||
|
||||
RUN if [ $ROCKYLINUX -eq 0 ]; then \N
|
||||
apt-get update && apt-get install --no-install-recommends -y wget libc6-dev ca-certificates ocl-icd-libopencl1 && \N
|
||||
cd /runtime && \N
|
||||
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-level-zero-gpu_1.3.30049.6_amd64.deb && \N
|
||||
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-opencl-icd_24.26.30049.6_amd64.deb && \N
|
||||
wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/libigdgmm12_22.3.20_amd64.deb && \N
|
||||
wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero-devel_1.17.6+u22.04_amd64.deb && \N
|
||||
wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero_1.17.6+u22.04_amd64.deb && \N
|
||||
dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && \N
|
||||
rm -rf /var/lib/apt/lists/\*; \N
|
||||
else \N
|
||||
source /etc/os-release && dnf install -y gcc jq wget 'dnf-command(config-manager)' && \N
|
||||
dnf config-manager --add-repo https://repositories.intel.com/gpu/rhel/${VERSION_ID}/lts/2350/unified/intel-gpu-${VERSION_ID}.repo && \N
|
||||
dnf install -y intel-opencl level-zero level-zero-devel intel-level-zero-gpu intel-gmmlib intel-ocloc && \N
|
||||
dnf clean all && \N
|
||||
LATEST_GO=$(curl --no-progress-meter https://go.dev/dl/?mode=json | jq ".[] | select(.version | startswith(\"go${CGO_VERSION}\")).version" | tr -d "\"") && \N
|
||||
wget -q https://go.dev/dl/$LATEST_GO.linux-amd64.tar.gz -O - | tar -xz -C /usr/local && \N
|
||||
cp -a /etc/OpenCL /usr/lib64/libocloc.so /usr/lib64/libze_intel_gpu.* /usr/lib64/libze_loader.* /usr/lib64/libigdgmm.* /runtime/ && \N
|
||||
mkdir /runtime/licenses/ && cd /usr/share/licenses/ && cp -a level-zero intel-gmmlib intel-level-zero-gpu intel-ocloc /runtime/licenses/; \N
|
||||
fi
|
||||
|
||||
ARG EP=_ENTRYPOINT_
|
||||
ARG CMD
|
||||
|
||||
WORKDIR ${DIR}
|
||||
COPY . .
|
||||
|
||||
RUN export PATH=$PATH:/usr/local/go/bin/ && cd cmd/${CMD} && \N
|
||||
GO111MODULE=on CGO_ENABLED=1 go install $CGOFLAGS --gcflags="$GCFLAGS" --asmflags="$ASMFLAGS" --ldflags="$LDFLAGS"
|
||||
RUN [ $ROCKYLINUX -eq 0 ] && install -D /go/bin/${CMD} /install_root${EP} || install -D /root/go/bin/${CMD} /install_root${EP}
|
||||
|
||||
#include "default_licenses.docker"
|
||||
|
||||
FROM ${FINAL_BASE_DYN}
|
||||
|
||||
ARG CMD
|
||||
ARG ROCKYLINUX
|
||||
|
||||
COPY --from=builder /runtime /runtime
|
||||
|
||||
RUN if [ $ROCKYLINUX -eq 0 ]; then \N
|
||||
apt-get update && apt-get install --no-install-recommends -y ocl-icd-libopencl1 && \N
|
||||
rm /runtime/level-zero-devel_*.deb && \N
|
||||
cd /runtime && dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && rm -rf /runtime && \N
|
||||
rm "/lib/x86_64-linux-gnu/libze_validation"* && rm "/lib/x86_64-linux-gnu/libze_tracing_layer"*; \N
|
||||
else \N
|
||||
cp -a /runtime//*.so* /usr/lib64/ && cp -a /runtime/OpenCL /etc/ && cp -a /runtime/licenses/* /usr/share/licenses/; \N
|
||||
fi
|
||||
|
||||
#include "default_end.docker"
|
||||
#include "default_labels.docker"
|
||||
|
||||
LABEL name='intel-gpu-levelzero'
|
||||
LABEL summary='Intel® GPU levelzero for Kubernetes'
|
||||
LABEL description='The GPU levelzero container provides access to Levelzero API for the Intel GPU plugin'
|
229
cmd/gpu_levelzero/main.go
Normal file
229
cmd/gpu_levelzero/main.go
Normal file
@ -0,0 +1,229 @@
|
||||
// Copyright 2024 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
// 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 main
|
||||
|
||||
// #cgo CFLAGS: "-I/usr/include/level_zero" "-Wall" "-Wextra" "-O2"
|
||||
// #cgo LDFLAGS: "-lze_loader"
|
||||
// #include "ze.h"
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
|
||||
levelzero "github.com/intel/intel-device-plugins-for-kubernetes/cmd/internal/levelzero"
|
||||
"google.golang.org/grpc"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
type server struct {
|
||||
levelzero.UnimplementedLevelzeroServer
|
||||
}
|
||||
|
||||
func retrieveStatusDescription(code uint32) string {
|
||||
bSize := 64
|
||||
b := make([]byte, bSize)
|
||||
|
||||
cwritten := C.ze_status_to_string(C.uint32_t(code), (*C.char)(unsafe.Pointer(&b[0])), C.uint32_t(bSize))
|
||||
|
||||
written := int(cwritten)
|
||||
if written <= 0 {
|
||||
return "failed to retrieve description"
|
||||
}
|
||||
|
||||
return string(b[0:written])
|
||||
}
|
||||
|
||||
func (s *server) GetDeviceHealth(c context.Context, deviceid *levelzero.DeviceId) (*levelzero.DeviceHealth, error) {
|
||||
klog.V(3).Infof("Retrieve device health for %s", deviceid.BdfAddress)
|
||||
|
||||
var errorVal uint32 = 0
|
||||
|
||||
cBdfAddress := C.CString(deviceid.BdfAddress)
|
||||
|
||||
memHealth := bool(C.zes_device_memory_is_healthy(cBdfAddress, (*C.uint32_t)(unsafe.Pointer(&errorVal))))
|
||||
if errorVal != 0 {
|
||||
klog.Warningf("device memory health read returned an error: 0x%X", errorVal)
|
||||
}
|
||||
|
||||
busHealth := bool(C.zes_device_bus_is_healthy(cBdfAddress, (*C.uint32_t)(unsafe.Pointer(&errorVal))))
|
||||
if errorVal != 0 {
|
||||
klog.Warningf("device bus health read returned an error: 0x%X", errorVal)
|
||||
}
|
||||
|
||||
var err levelzero.Error
|
||||
if errorVal != 0 {
|
||||
err.Errorcode = errorVal
|
||||
err.Description = retrieveStatusDescription(errorVal)
|
||||
} else {
|
||||
klog.V(3).Infof("Health for %s: Memory=%t, Bus=%t", deviceid.BdfAddress, memHealth, busHealth)
|
||||
}
|
||||
|
||||
health := &levelzero.DeviceHealth{
|
||||
BusOk: busHealth,
|
||||
MemoryOk: memHealth,
|
||||
SocOk: true, // Placeholder, not available.
|
||||
Error: &err,
|
||||
}
|
||||
|
||||
return health, nil
|
||||
}
|
||||
|
||||
func (s *server) GetDeviceTemperature(c context.Context, deviceid *levelzero.DeviceId) (*levelzero.DeviceTemperature, error) {
|
||||
klog.V(3).Infof("Retrieve device temperature for %s", deviceid.BdfAddress)
|
||||
|
||||
var errorVal uint32 = 0
|
||||
|
||||
cBdfAddress := C.CString(deviceid.BdfAddress)
|
||||
|
||||
globalTemp := float64(C.zes_device_temp_max(cBdfAddress, C.CString("global"), (*C.uint32_t)(unsafe.Pointer(&errorVal))))
|
||||
if errorVal != 0 {
|
||||
klog.Warningf("global temperature read returned an error: 0x%X", errorVal)
|
||||
}
|
||||
|
||||
gpuTemp := float64(C.zes_device_temp_max(cBdfAddress, C.CString("gpu"), (*C.uint32_t)(unsafe.Pointer(&errorVal))))
|
||||
if errorVal != 0 {
|
||||
klog.Warningf("gpu temperature read returned an error: 0x%X", errorVal)
|
||||
}
|
||||
|
||||
memTemp := float64(C.zes_device_temp_max(cBdfAddress, C.CString("memory"), (*C.uint32_t)(unsafe.Pointer(&errorVal))))
|
||||
if errorVal != 0 {
|
||||
klog.Warningf("memory temperature read returned an error: 0x%X", errorVal)
|
||||
}
|
||||
|
||||
var err levelzero.Error
|
||||
if errorVal != 0 {
|
||||
err.Errorcode = errorVal
|
||||
err.Description = retrieveStatusDescription(errorVal)
|
||||
} else {
|
||||
klog.V(3).Infof("Temperatures for %s: Memory=%.1fC, GPU=%.1fC, Global=%.1fC", deviceid.BdfAddress, memTemp, gpuTemp, globalTemp)
|
||||
}
|
||||
|
||||
temps := &levelzero.DeviceTemperature{
|
||||
Global: globalTemp,
|
||||
Gpu: gpuTemp,
|
||||
Memory: memTemp,
|
||||
Error: &err,
|
||||
}
|
||||
|
||||
return temps, nil
|
||||
}
|
||||
|
||||
func (s *server) GetIntelIndices(c context.Context, m *levelzero.GetIntelIndicesMessage) (*levelzero.DeviceIndices, error) {
|
||||
klog.V(3).Infof("Retrieve Intel indices")
|
||||
|
||||
errorVal := uint32(0)
|
||||
|
||||
indices := make([]uint32, 8)
|
||||
|
||||
// TODO: Move to zes_ version when crash in WSL env is fixed:
|
||||
// https://github.com/intel/compute-runtime/issues/721
|
||||
count := C.ze_intel_device_indices((*C.uint32_t)(&indices[0]), C.uint32_t(len(indices)), (*C.uint32_t)(unsafe.Pointer(&errorVal)))
|
||||
|
||||
var err levelzero.Error
|
||||
if errorVal != 0 {
|
||||
err.Errorcode = errorVal
|
||||
err.Description = retrieveStatusDescription(errorVal)
|
||||
}
|
||||
|
||||
ret := levelzero.DeviceIndices{
|
||||
Indices: indices[0:count],
|
||||
Error: &err,
|
||||
}
|
||||
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *server) GetDeviceMemoryAmount(c context.Context, deviceid *levelzero.DeviceId) (*levelzero.DeviceMemoryAmount, error) {
|
||||
klog.V(3).Infof("Retrieve device memory amount for %s", deviceid.BdfAddress)
|
||||
|
||||
errorVal := uint32(0)
|
||||
|
||||
memSize := C.zes_device_memory_amount(C.CString(deviceid.BdfAddress), (*C.uint32_t)(unsafe.Pointer(&errorVal)))
|
||||
|
||||
if errorVal != 0 {
|
||||
klog.Warningf("device memory amount read returned an error: 0x%X", errorVal)
|
||||
}
|
||||
|
||||
description := retrieveStatusDescription(errorVal)
|
||||
|
||||
var err levelzero.Error
|
||||
if errorVal != 0 {
|
||||
err.Errorcode = errorVal
|
||||
err.Description = description
|
||||
}
|
||||
|
||||
ret := levelzero.DeviceMemoryAmount{
|
||||
MemorySize: uint64(memSize),
|
||||
Error: &err,
|
||||
}
|
||||
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
|
||||
socketPath := flag.String("socket", levelzero.DefaultUnixSocketPath, "Unix socket path to listen on")
|
||||
wslEnv := flag.Bool("wsl", false, "Running in WSL environment")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
// Delete possible previous socket file
|
||||
_ = os.Remove(*socketPath)
|
||||
|
||||
verbosity := int64(0)
|
||||
|
||||
flag.VisitAll(func(f *flag.Flag) {
|
||||
if f.Name == "v" {
|
||||
if v, err := strconv.ParseInt(f.Value.String(), 10, 16); err == nil {
|
||||
verbosity = v
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
lis, err := net.Listen("unix", *socketPath)
|
||||
if err != nil {
|
||||
klog.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
|
||||
// TODO: Drop "ze_try_initialize" when crash in WSL env is fixed:
|
||||
// https://github.com/intel/compute-runtime/issues/721
|
||||
if *wslEnv {
|
||||
if !bool(C.ze_try_initialize()) {
|
||||
klog.Fatal("Ze Init try failed, cannot continue")
|
||||
}
|
||||
} else {
|
||||
if !bool(C.zes_try_initialize()) {
|
||||
klog.Fatal("Zes Init try failed, cannot continue")
|
||||
}
|
||||
}
|
||||
|
||||
C.zes_set_verbosity(C.int(verbosity))
|
||||
|
||||
s := grpc.NewServer()
|
||||
|
||||
levelzero.RegisterLevelzeroServer(s, &server{})
|
||||
|
||||
klog.Infof("server listening at %v", lis.Addr())
|
||||
|
||||
if err := s.Serve(lis); err != nil {
|
||||
klog.Fatalf("failed to serve: %v", err)
|
||||
}
|
||||
}
|
88
cmd/gpu_levelzero/main_test.go
Normal file
88
cmd/gpu_levelzero/main_test.go
Normal file
@ -0,0 +1,88 @@
|
||||
// Copyright 2024 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
// 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 main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
levelzero "github.com/intel/intel-device-plugins-for-kubernetes/cmd/internal/levelzero"
|
||||
)
|
||||
|
||||
func TestErrorConversion(t *testing.T) {
|
||||
t.Run("Known conversion(s)", func(t *testing.T) {
|
||||
desc := retrieveStatusDescription(0)
|
||||
|
||||
if desc != "success (0x0)" {
|
||||
t.Fatal("couldn't convert 0 to success: ", desc)
|
||||
}
|
||||
|
||||
desc = retrieveStatusDescription(1879048193) // device lost
|
||||
|
||||
if desc != "device lost (0x70000001)" {
|
||||
t.Fatal("couldn't convert 0 to success: ", desc)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestCallingMethods(t *testing.T) {
|
||||
s := server{}
|
||||
|
||||
// As we cannot control the testing environment, we can't really check the return values for any sane values.
|
||||
|
||||
t.Run("Call get indices", func(t *testing.T) {
|
||||
indices, err := s.GetIntelIndices(context.Background(), &levelzero.GetIntelIndicesMessage{})
|
||||
|
||||
if len(indices.Indices) == 0 {
|
||||
t.Log("No indices received")
|
||||
}
|
||||
if err != nil {
|
||||
t.Log("Received an error")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Call get health", func(t *testing.T) {
|
||||
health, err := s.GetDeviceHealth(context.Background(), &levelzero.DeviceId{BdfAddress: "0000:00:01.0"})
|
||||
|
||||
if health.MemoryOk {
|
||||
t.Log("Memory is ok")
|
||||
}
|
||||
if err != nil {
|
||||
t.Log("Received an error")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Call get temperature", func(t *testing.T) {
|
||||
temps, err := s.GetDeviceTemperature(context.Background(), &levelzero.DeviceId{BdfAddress: "0000:00:01.0"})
|
||||
|
||||
if temps.Global > -999.0 {
|
||||
t.Log("Memory is ok")
|
||||
}
|
||||
if err != nil {
|
||||
t.Log("Received an error")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Call get memory", func(t *testing.T) {
|
||||
amount, err := s.GetDeviceMemoryAmount(context.Background(), &levelzero.DeviceId{BdfAddress: "0000:00:01.0"})
|
||||
|
||||
if amount.MemorySize > 0 {
|
||||
t.Log("Received some memory")
|
||||
}
|
||||
if err != nil {
|
||||
t.Log("Received an error")
|
||||
}
|
||||
})
|
||||
}
|
177
cmd/gpu_levelzero/ze.c
Normal file
177
cmd/gpu_levelzero/ze.c
Normal file
@ -0,0 +1,177 @@
|
||||
// Copyright 2024 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ze_api.h>
|
||||
|
||||
#include "ze.h"
|
||||
|
||||
int ze_status_to_string(const uint32_t error, char* out, uint32_t out_size)
|
||||
{
|
||||
char* description;
|
||||
|
||||
switch (error) {
|
||||
case ZE_RESULT_SUCCESS:
|
||||
description = "success"; break;
|
||||
case ZE_RESULT_NOT_READY:
|
||||
description = "not ready"; break;
|
||||
case ZE_RESULT_ERROR_DEVICE_LOST:
|
||||
description = "device lost"; break;
|
||||
case ZE_RESULT_ERROR_DEVICE_REQUIRES_RESET:
|
||||
description = "device requires reset"; break;
|
||||
case ZE_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE:
|
||||
description = "device in low power state"; break;
|
||||
case ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS:
|
||||
description = "insufficient permissions"; break;
|
||||
case ZE_RESULT_ERROR_NOT_AVAILABLE:
|
||||
description = "not available"; break;
|
||||
case ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE:
|
||||
description = "dependency unavailable"; break;
|
||||
case ZE_RESULT_ERROR_UNINITIALIZED:
|
||||
description = "uninitialized"; break;
|
||||
case ZE_RESULT_ERROR_UNSUPPORTED_VERSION:
|
||||
description = "unsupported version"; break;
|
||||
case ZE_RESULT_ERROR_UNSUPPORTED_FEATURE:
|
||||
description = "unsupported feature"; break;
|
||||
case ZE_RESULT_ERROR_INVALID_ARGUMENT:
|
||||
description = "invalid argument"; break;
|
||||
case ZE_RESULT_ERROR_INVALID_NULL_POINTER:
|
||||
description = "invalid null pointer"; break;
|
||||
case ZE_RESULT_ERROR_INVALID_NULL_HANDLE:
|
||||
description = "invalid null handle"; break;
|
||||
case ZE_RESULT_ERROR_UNKNOWN:
|
||||
description = "unknown"; break;
|
||||
default:
|
||||
description = "not known"; break;
|
||||
}
|
||||
|
||||
return snprintf(out, out_size -1, "%s (0x%X)", description, error);
|
||||
}
|
||||
|
||||
static ze_driver_handle_t initialize_ze(void)
|
||||
{
|
||||
ze_result_t res = zeInit(ZE_INIT_FLAG_GPU_ONLY);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
fprintf(stderr, "zeInit failed: 0x%X \n", res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t count = 0;
|
||||
|
||||
if (zeDriverGet(&count, NULL) != ZE_RESULT_SUCCESS || count == 0) {
|
||||
fprintf(stderr, "zeDriverGet failed or no drivers\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
count = 1;
|
||||
|
||||
ze_driver_handle_t handle;
|
||||
if (zeDriverGet(&count, &handle) != ZE_RESULT_SUCCESS) {
|
||||
fprintf(stderr, "zeDriverGet failed\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
bool ze_try_initialize(void)
|
||||
{
|
||||
if (getenv("UNITTEST") != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return zeInit(0) == ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/// @brief Retrieve indices for Intel levelzero devices
|
||||
/// @param indices Pointer to an array to store indices
|
||||
/// @param indices_size Size of the array
|
||||
/// @return Number of indices stored
|
||||
int ze_intel_device_indices(uint32_t* indices, uint32_t indices_size, uint32_t *error)
|
||||
{
|
||||
if (getenv("UNITTEST") != NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (indices == NULL || 0 == indices_size) {
|
||||
*error = ZE_RESULT_ERROR_INVALID_NULL_POINTER;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ze_driver_handle_t handle = initialize_ze();
|
||||
|
||||
if (handle == 0) {
|
||||
*error = ZE_RESULT_ERROR_INVALID_NULL_POINTER;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ze_result_t res = 0;
|
||||
uint32_t count = 0;
|
||||
|
||||
res = zeDeviceGet(handle, &count, NULL);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
*error = ZE_RESULT_ERROR_DEVICE_LOST;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ze_device_handle_t dev_handle[count];
|
||||
|
||||
res = zeDeviceGet(handle, &count, dev_handle);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (count > indices_size) {
|
||||
count = indices_size;
|
||||
}
|
||||
|
||||
int intel_device_count = 0;
|
||||
|
||||
// Iterate over the devices and add Intel indices to be returned
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
ze_device_handle_t dev_h = dev_handle[i];
|
||||
|
||||
ze_device_properties_t dev_prop;
|
||||
memset(&dev_prop, 0, sizeof(ze_device_properties_t));
|
||||
|
||||
res = zeDeviceGetProperties(dev_h, &dev_prop);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dev_prop.vendorId == VENDOR_ID_INTEL) {
|
||||
indices[intel_device_count] = i;
|
||||
intel_device_count++;
|
||||
}
|
||||
}
|
||||
|
||||
return intel_device_count;
|
||||
}
|
33
cmd/gpu_levelzero/ze.h
Normal file
33
cmd/gpu_levelzero/ze.h
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2024 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define VENDOR_ID_INTEL 0x8086
|
||||
|
||||
void zes_set_verbosity(const int level);
|
||||
|
||||
bool ze_try_initialize(void);
|
||||
bool zes_try_initialize(void);
|
||||
|
||||
int ze_status_to_string(const uint32_t error, char* out, uint32_t out_size);
|
||||
|
||||
int ze_intel_device_indices(uint32_t* indices, uint32_t indices_size, uint32_t* error);
|
||||
uint64_t zes_device_memory_amount(char* bdf_address, uint32_t* error);
|
||||
bool zes_device_memory_is_healthy(char* bdf_address, uint32_t* error);
|
||||
bool zes_device_bus_is_healthy(char* bdf_address, uint32_t* error);
|
||||
double zes_device_temp_max(char* bdf_address, char* sensor, uint32_t* error);
|
438
cmd/gpu_levelzero/zes.c
Normal file
438
cmd/gpu_levelzero/zes.c
Normal file
@ -0,0 +1,438 @@
|
||||
// Copyright 2024 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <zes_api.h>
|
||||
|
||||
#include "ze.h"
|
||||
|
||||
#define MAX_BDF_BUFSIZE 32
|
||||
|
||||
struct device_info {
|
||||
char bdf[MAX_BDF_BUFSIZE];
|
||||
};
|
||||
|
||||
zes_device_handle_t* zes_handles = NULL;
|
||||
struct device_info* bdf_addresses = NULL;
|
||||
uint32_t zes_handles_count = 0;
|
||||
|
||||
static bool device_enumerated = false;
|
||||
|
||||
typedef enum {
|
||||
LOG_ERROR = 1,
|
||||
LOG_WARNING,
|
||||
LOG_INFO,
|
||||
LOG_DEBUG
|
||||
} log_level_t;
|
||||
|
||||
static log_level_t verbosity_level = LOG_ERROR;
|
||||
|
||||
static void print_log(log_level_t level, char* fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
static void print_log(log_level_t level, char* fmt, ...)
|
||||
{
|
||||
if (verbosity_level >= level) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
void zes_set_verbosity(const int level)
|
||||
{
|
||||
verbosity_level = level;
|
||||
|
||||
fprintf(stderr, "C set verbosity level: %d\n", verbosity_level);
|
||||
}
|
||||
|
||||
bool zes_try_initialize(void)
|
||||
{
|
||||
if (getenv("UNITTEST") != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return zesInit(0) == ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static ze_result_t enumerate_zes_devices(void)
|
||||
{
|
||||
ze_result_t res = zesInit(0);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t count = 0;
|
||||
|
||||
res = zesDriverGet(&count, NULL);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (count > 1) {
|
||||
print_log(LOG_WARNING, "more than one zes driver detected, using first one\n");
|
||||
}
|
||||
|
||||
count = 1;
|
||||
|
||||
zes_driver_handle_t handle;
|
||||
res = zesDriverGet(&count, &handle);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
return res;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
res = zesDeviceGet(handle, &count, NULL);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
zes_handles = calloc(count, sizeof(zes_device_handle_t));
|
||||
|
||||
res = zesDeviceGet(handle, &count, zes_handles);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
free(zes_handles);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
zes_handles_count = count;
|
||||
|
||||
bdf_addresses = (struct device_info*) calloc(count,sizeof(struct device_info));
|
||||
if (bdf_addresses == NULL) {
|
||||
free(zes_handles);
|
||||
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
// Iterate over the devices and store their info into the cache array
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
zes_device_handle_t dev_h = zes_handles[i];
|
||||
|
||||
zes_pci_properties_t pci_props;
|
||||
if (zesDevicePciGetProperties(dev_h, &pci_props) != ZE_RESULT_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
zes_pci_address_t* addr = &pci_props.address;
|
||||
|
||||
snprintf(bdf_addresses[i].bdf, sizeof(bdf_addresses[i].bdf),
|
||||
"%04x:%02x:%02x.%x",
|
||||
addr->domain, addr->bus, addr->device, addr->function
|
||||
);
|
||||
}
|
||||
|
||||
device_enumerated = true;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static zes_device_handle_t retrieve_handle_for_bdf(char* bdf_address)
|
||||
{
|
||||
zes_device_handle_t handle = 0;
|
||||
|
||||
for (uint32_t i = 0; i < zes_handles_count; ++i) {
|
||||
struct device_info* di = &bdf_addresses[i];
|
||||
|
||||
if (strncmp(bdf_address, di->bdf, sizeof(di->bdf)) == 0) {
|
||||
handle = zes_handles[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
static bool is_integrated(zes_device_handle_t handle)
|
||||
{
|
||||
ze_result_t res = ZE_RESULT_SUCCESS;
|
||||
|
||||
zes_device_ext_properties_t ext = {
|
||||
.stype = ZES_STRUCTURE_TYPE_DEVICE_EXT_PROPERTIES,
|
||||
};
|
||||
zes_device_properties_t props = {
|
||||
.stype = ZES_STRUCTURE_TYPE_DEVICE_PROPERTIES,
|
||||
.pNext = &ext,
|
||||
};
|
||||
|
||||
if (res = zesDeviceGetProperties(handle, &props), res == ZE_RESULT_SUCCESS) {
|
||||
if (ext.flags & ZES_DEVICE_PROPERTY_FLAG_INTEGRATED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @brief Retrieves memory amount for a specific device with bdf address
|
||||
/// @param bdf_address
|
||||
/// @return memory amount for the device
|
||||
uint64_t zes_device_memory_amount(char* bdf_address, uint32_t* error)
|
||||
{
|
||||
if (getenv("UNITTEST") != NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
print_log(LOG_DEBUG, "Retrieve memory size for %s\n", bdf_address);
|
||||
|
||||
ze_result_t res = ZE_RESULT_SUCCESS;
|
||||
|
||||
if (!device_enumerated) {
|
||||
res = enumerate_zes_devices();
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
zes_device_handle_t handle = retrieve_handle_for_bdf(bdf_address);
|
||||
if (handle == 0) {
|
||||
*error = ZE_RESULT_ERROR_UNKNOWN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Levelzero does not provide memory details for integrated
|
||||
if (is_integrated(handle)) {
|
||||
print_log(LOG_DEBUG, "Device is integrated => no memory\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t modcount = 0;
|
||||
uint64_t memory_size = 0;
|
||||
if (!zesDeviceEnumMemoryModules(handle, &modcount, NULL) == ZE_RESULT_SUCCESS && modcount > 0) {
|
||||
zes_mem_handle_t memhandles[modcount];
|
||||
|
||||
if (zesDeviceEnumMemoryModules(handle, &modcount, memhandles) == ZE_RESULT_SUCCESS) {
|
||||
for (uint32_t mod_index = 0; mod_index < modcount; ++mod_index) {
|
||||
zes_mem_state_t mem_state;
|
||||
|
||||
if (zesMemoryGetState(memhandles[mod_index], &mem_state) == ZE_RESULT_SUCCESS) {
|
||||
memory_size += mem_state.size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_log(LOG_DEBUG, "> Memory size: %ld\n", memory_size);
|
||||
|
||||
return memory_size;
|
||||
}
|
||||
|
||||
/// @brief Retrieve device memory's health status
|
||||
/// @param bdf_address
|
||||
/// @return true for good, false for bad
|
||||
bool zes_device_memory_is_healthy(char* bdf_address, uint32_t* error)
|
||||
{
|
||||
if (getenv("UNITTEST") != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
print_log(LOG_DEBUG, "Fetching memory health for %s\n", bdf_address);
|
||||
|
||||
if (!device_enumerated) {
|
||||
ze_result_t res = enumerate_zes_devices();
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
zes_device_handle_t handle = retrieve_handle_for_bdf(bdf_address);
|
||||
if (handle == 0) {
|
||||
*error = ZE_RESULT_ERROR_UNKNOWN;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Levelzero does not provide memory details for integrated
|
||||
if (is_integrated(handle)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t modcount = 0;
|
||||
if (zesDeviceEnumMemoryModules(handle, &modcount, NULL) == ZE_RESULT_SUCCESS && modcount > 0) {
|
||||
zes_mem_handle_t memhandles[modcount];
|
||||
|
||||
if (zesDeviceEnumMemoryModules(handle, &modcount, memhandles) == ZE_RESULT_SUCCESS) {
|
||||
for (uint32_t mod_index = 0; mod_index < modcount; ++mod_index) {
|
||||
zes_mem_state_t mem_state;
|
||||
|
||||
if (zesMemoryGetState(memhandles[mod_index], &mem_state) == ZE_RESULT_SUCCESS) {
|
||||
if (mem_state.health >= ZES_MEM_HEALTH_CRITICAL) {
|
||||
print_log(LOG_DEBUG, "> Health: Critical\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_log(LOG_DEBUG, "> Health: OK\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @brief Retrieve device bus' health status
|
||||
/// @param bdf_address
|
||||
/// @return true for good, false for bad
|
||||
bool zes_device_bus_is_healthy(char* bdf_address, uint32_t* error)
|
||||
{
|
||||
if (getenv("UNITTEST") != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
print_log(LOG_DEBUG, "Fetching bus health for %s\n", bdf_address);
|
||||
|
||||
if (!device_enumerated) {
|
||||
ze_result_t res = enumerate_zes_devices();
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
zes_device_handle_t handle = retrieve_handle_for_bdf(bdf_address);
|
||||
if (handle == 0) {
|
||||
*error = ZE_RESULT_ERROR_UNKNOWN;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
zes_pci_state_t pci_state;
|
||||
memset(&pci_state, 0, sizeof(pci_state));
|
||||
|
||||
ze_result_t res = zesDevicePciGetState(handle, &pci_state);
|
||||
if (res == ZE_RESULT_SUCCESS) {
|
||||
if (pci_state.qualityIssues & ZES_PCI_LINK_QUAL_ISSUE_FLAG_SPEED) {
|
||||
print_log(LOG_DEBUG, "> Health: Critical\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
} else if (res != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
|
||||
*error = res;
|
||||
}
|
||||
|
||||
print_log(LOG_DEBUG, "> Health: OK\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @brief Retrieve device's temperatur for a sensor
|
||||
/// @param bdf_address - bdf address
|
||||
/// @param sensor - name of the sensor: global, gpu or memory
|
||||
/// @return temperature for the sensor
|
||||
double zes_device_temp_max(char* bdf_address, char* sensor, uint32_t* error)
|
||||
{
|
||||
if (getenv("UNITTEST") != NULL) {
|
||||
return -999.0;
|
||||
}
|
||||
|
||||
uint32_t requestedType = 0;
|
||||
if (!strncmp("global", sensor, 6)) {
|
||||
requestedType = ZES_TEMP_SENSORS_GLOBAL;
|
||||
} else if (!strncmp("gpu", sensor, 3)) {
|
||||
requestedType = ZES_TEMP_SENSORS_GPU;
|
||||
} else if (!strncmp("memory", sensor, 6)) {
|
||||
requestedType = ZES_TEMP_SENSORS_MEMORY;
|
||||
} else {
|
||||
*error = ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
return -999.0;
|
||||
}
|
||||
|
||||
print_log(LOG_DEBUG, "Fetch %s temperature for %s\n", sensor, bdf_address);
|
||||
|
||||
if (!device_enumerated) {
|
||||
ze_result_t res = enumerate_zes_devices();
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return -999.0;
|
||||
}
|
||||
}
|
||||
|
||||
zes_device_handle_t handle = retrieve_handle_for_bdf(bdf_address);
|
||||
if (handle == 0) {
|
||||
*error = ZE_RESULT_ERROR_UNKNOWN;
|
||||
|
||||
return -999.0;
|
||||
}
|
||||
|
||||
uint32_t count = 0;
|
||||
ze_result_t res = zesDeviceEnumTemperatureSensors(handle, &count, NULL);
|
||||
if (res != ZE_RESULT_SUCCESS || count == 0) {
|
||||
*error = res;
|
||||
|
||||
return -999.0;
|
||||
}
|
||||
|
||||
zes_temp_handle_t tempHandles[count];
|
||||
res = zesDeviceEnumTemperatureSensors(handle, &count, tempHandles);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return -999.0;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
zes_temp_properties_t props;
|
||||
|
||||
res = zesTemperatureGetProperties(tempHandles[i], &props);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return -999.0;
|
||||
}
|
||||
|
||||
if (props.type != requestedType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double tempCelsius = 0.0;
|
||||
res = zesTemperatureGetState(tempHandles[i], &tempCelsius);
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
*error = res;
|
||||
|
||||
return -999.0;
|
||||
}
|
||||
|
||||
print_log(LOG_DEBUG, "> Temperature: %.1f\n", tempCelsius);
|
||||
|
||||
return tempCelsius;
|
||||
}
|
||||
|
||||
*error = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return -999.0;
|
||||
}
|
19
cmd/internal/levelzero/levelzero.go
Normal file
19
cmd/internal/levelzero/levelzero.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2024 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
// 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 gpulevelzero
|
||||
|
||||
const (
|
||||
DefaultUnixSocketPath = "/var/lib/levelzero/server.sock"
|
||||
)
|
637
cmd/internal/levelzero/levelzero.pb.go
Normal file
637
cmd/internal/levelzero/levelzero.pb.go
Normal file
@ -0,0 +1,637 @@
|
||||
// Copyright 2024 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.12.4
|
||||
// source: levelzero.proto
|
||||
|
||||
package gpulevelzero
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type GetIntelIndicesMessage struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *GetIntelIndicesMessage) Reset() {
|
||||
*x = GetIntelIndicesMessage{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_levelzero_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetIntelIndicesMessage) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetIntelIndicesMessage) ProtoMessage() {}
|
||||
|
||||
func (x *GetIntelIndicesMessage) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_levelzero_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetIntelIndicesMessage.ProtoReflect.Descriptor instead.
|
||||
func (*GetIntelIndicesMessage) Descriptor() ([]byte, []int) {
|
||||
return file_levelzero_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type DeviceId struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
BdfAddress string `protobuf:"bytes,1,opt,name=bdfAddress,proto3" json:"bdfAddress,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DeviceId) Reset() {
|
||||
*x = DeviceId{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_levelzero_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DeviceId) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeviceId) ProtoMessage() {}
|
||||
|
||||
func (x *DeviceId) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_levelzero_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeviceId.ProtoReflect.Descriptor instead.
|
||||
func (*DeviceId) Descriptor() ([]byte, []int) {
|
||||
return file_levelzero_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *DeviceId) GetBdfAddress() string {
|
||||
if x != nil {
|
||||
return x.BdfAddress
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type DeviceHealth struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
MemoryOk bool `protobuf:"varint,1,opt,name=memory_ok,json=memoryOk,proto3" json:"memory_ok,omitempty"`
|
||||
BusOk bool `protobuf:"varint,2,opt,name=bus_ok,json=busOk,proto3" json:"bus_ok,omitempty"`
|
||||
SocOk bool `protobuf:"varint,3,opt,name=soc_ok,json=socOk,proto3" json:"soc_ok,omitempty"`
|
||||
Error *Error `protobuf:"bytes,42,opt,name=error,proto3" json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DeviceHealth) Reset() {
|
||||
*x = DeviceHealth{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_levelzero_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DeviceHealth) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeviceHealth) ProtoMessage() {}
|
||||
|
||||
func (x *DeviceHealth) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_levelzero_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeviceHealth.ProtoReflect.Descriptor instead.
|
||||
func (*DeviceHealth) Descriptor() ([]byte, []int) {
|
||||
return file_levelzero_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *DeviceHealth) GetMemoryOk() bool {
|
||||
if x != nil {
|
||||
return x.MemoryOk
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *DeviceHealth) GetBusOk() bool {
|
||||
if x != nil {
|
||||
return x.BusOk
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *DeviceHealth) GetSocOk() bool {
|
||||
if x != nil {
|
||||
return x.SocOk
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *DeviceHealth) GetError() *Error {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeviceTemperature struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Global float64 `protobuf:"fixed64,1,opt,name=global,proto3" json:"global,omitempty"`
|
||||
Gpu float64 `protobuf:"fixed64,2,opt,name=gpu,proto3" json:"gpu,omitempty"`
|
||||
Memory float64 `protobuf:"fixed64,3,opt,name=memory,proto3" json:"memory,omitempty"`
|
||||
Error *Error `protobuf:"bytes,42,opt,name=error,proto3" json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DeviceTemperature) Reset() {
|
||||
*x = DeviceTemperature{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_levelzero_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DeviceTemperature) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeviceTemperature) ProtoMessage() {}
|
||||
|
||||
func (x *DeviceTemperature) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_levelzero_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeviceTemperature.ProtoReflect.Descriptor instead.
|
||||
func (*DeviceTemperature) Descriptor() ([]byte, []int) {
|
||||
return file_levelzero_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *DeviceTemperature) GetGlobal() float64 {
|
||||
if x != nil {
|
||||
return x.Global
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DeviceTemperature) GetGpu() float64 {
|
||||
if x != nil {
|
||||
return x.Gpu
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DeviceTemperature) GetMemory() float64 {
|
||||
if x != nil {
|
||||
return x.Memory
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DeviceTemperature) GetError() *Error {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeviceIndices struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Indices []uint32 `protobuf:"varint,1,rep,packed,name=indices,proto3" json:"indices,omitempty"`
|
||||
Error *Error `protobuf:"bytes,42,opt,name=error,proto3" json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DeviceIndices) Reset() {
|
||||
*x = DeviceIndices{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_levelzero_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DeviceIndices) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeviceIndices) ProtoMessage() {}
|
||||
|
||||
func (x *DeviceIndices) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_levelzero_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeviceIndices.ProtoReflect.Descriptor instead.
|
||||
func (*DeviceIndices) Descriptor() ([]byte, []int) {
|
||||
return file_levelzero_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *DeviceIndices) GetIndices() []uint32 {
|
||||
if x != nil {
|
||||
return x.Indices
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *DeviceIndices) GetError() *Error {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeviceMemoryAmount struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
MemorySize uint64 `protobuf:"varint,1,opt,name=memory_size,json=memorySize,proto3" json:"memory_size,omitempty"`
|
||||
Error *Error `protobuf:"bytes,42,opt,name=error,proto3" json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DeviceMemoryAmount) Reset() {
|
||||
*x = DeviceMemoryAmount{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_levelzero_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DeviceMemoryAmount) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeviceMemoryAmount) ProtoMessage() {}
|
||||
|
||||
func (x *DeviceMemoryAmount) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_levelzero_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeviceMemoryAmount.ProtoReflect.Descriptor instead.
|
||||
func (*DeviceMemoryAmount) Descriptor() ([]byte, []int) {
|
||||
return file_levelzero_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *DeviceMemoryAmount) GetMemorySize() uint64 {
|
||||
if x != nil {
|
||||
return x.MemorySize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DeviceMemoryAmount) GetError() *Error {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"`
|
||||
Errorcode uint32 `protobuf:"varint,2,opt,name=errorcode,proto3" json:"errorcode,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Error) Reset() {
|
||||
*x = Error{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_levelzero_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Error) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Error) ProtoMessage() {}
|
||||
|
||||
func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_levelzero_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Error.ProtoReflect.Descriptor instead.
|
||||
func (*Error) Descriptor() ([]byte, []int) {
|
||||
return file_levelzero_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *Error) GetDescription() string {
|
||||
if x != nil {
|
||||
return x.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Error) GetErrorcode() uint32 {
|
||||
if x != nil {
|
||||
return x.Errorcode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_levelzero_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_levelzero_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x7a, 0x65, 0x72, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x22, 0x18, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x6c, 0x49, 0x6e, 0x64,
|
||||
0x69, 0x63, 0x65, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2a, 0x0a, 0x08, 0x44,
|
||||
0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x64, 0x66, 0x41, 0x64,
|
||||
0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x64, 0x66,
|
||||
0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x77, 0x0a, 0x0c, 0x44, 0x65, 0x76, 0x69, 0x63,
|
||||
0x65, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x65, 0x6d, 0x6f, 0x72,
|
||||
0x79, 0x5f, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6d, 0x65, 0x6d, 0x6f,
|
||||
0x72, 0x79, 0x4f, 0x6b, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x75, 0x73, 0x5f, 0x6f, 0x6b, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x62, 0x75, 0x73, 0x4f, 0x6b, 0x12, 0x15, 0x0a, 0x06, 0x73,
|
||||
0x6f, 0x63, 0x5f, 0x6f, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x73, 0x6f, 0x63,
|
||||
0x4f, 0x6b, 0x12, 0x1c, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x2a, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x06, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x22, 0x73, 0x0a, 0x11, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72,
|
||||
0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x10, 0x0a,
|
||||
0x03, 0x67, 0x70, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x67, 0x70, 0x75, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52,
|
||||
0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x18, 0x2a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05,
|
||||
0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x47, 0x0a, 0x0d, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49,
|
||||
0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x65,
|
||||
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x07, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73,
|
||||
0x12, 0x1c, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x2a, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x06, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x53,
|
||||
0x0a, 0x12, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x41, 0x6d,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x5f, 0x73,
|
||||
0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6d, 0x65, 0x6d, 0x6f, 0x72,
|
||||
0x79, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x2a,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72,
|
||||
0x72, 0x6f, 0x72, 0x22, 0x47, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x20, 0x0a, 0x0b,
|
||||
0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x0d, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x32, 0xec, 0x01, 0x0a,
|
||||
0x09, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x7a, 0x65, 0x72, 0x6f, 0x12, 0x2d, 0x0a, 0x0f, 0x47, 0x65,
|
||||
0x74, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x09, 0x2e,
|
||||
0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x1a, 0x0d, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63,
|
||||
0x65, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x14, 0x47, 0x65, 0x74,
|
||||
0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72,
|
||||
0x65, 0x12, 0x09, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x1a, 0x12, 0x2e, 0x44,
|
||||
0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65,
|
||||
0x22, 0x00, 0x12, 0x3c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x6c, 0x49, 0x6e,
|
||||
0x64, 0x69, 0x63, 0x65, 0x73, 0x12, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x6c,
|
||||
0x49, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x0e,
|
||||
0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x22, 0x00,
|
||||
0x12, 0x39, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x6d,
|
||||
0x6f, 0x72, 0x79, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x09, 0x2e, 0x44, 0x65, 0x76, 0x69,
|
||||
0x63, 0x65, 0x49, 0x64, 0x1a, 0x13, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x6d,
|
||||
0x6f, 0x72, 0x79, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x67,
|
||||
0x70, 0x75, 0x2e, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x7a, 0x65, 0x72, 0x6f, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_levelzero_proto_rawDescOnce sync.Once
|
||||
file_levelzero_proto_rawDescData = file_levelzero_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_levelzero_proto_rawDescGZIP() []byte {
|
||||
file_levelzero_proto_rawDescOnce.Do(func() {
|
||||
file_levelzero_proto_rawDescData = protoimpl.X.CompressGZIP(file_levelzero_proto_rawDescData)
|
||||
})
|
||||
return file_levelzero_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_levelzero_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_levelzero_proto_goTypes = []interface{}{
|
||||
(*GetIntelIndicesMessage)(nil), // 0: GetIntelIndicesMessage
|
||||
(*DeviceId)(nil), // 1: DeviceId
|
||||
(*DeviceHealth)(nil), // 2: DeviceHealth
|
||||
(*DeviceTemperature)(nil), // 3: DeviceTemperature
|
||||
(*DeviceIndices)(nil), // 4: DeviceIndices
|
||||
(*DeviceMemoryAmount)(nil), // 5: DeviceMemoryAmount
|
||||
(*Error)(nil), // 6: Error
|
||||
}
|
||||
var file_levelzero_proto_depIdxs = []int32{
|
||||
6, // 0: DeviceHealth.error:type_name -> Error
|
||||
6, // 1: DeviceTemperature.error:type_name -> Error
|
||||
6, // 2: DeviceIndices.error:type_name -> Error
|
||||
6, // 3: DeviceMemoryAmount.error:type_name -> Error
|
||||
1, // 4: Levelzero.GetDeviceHealth:input_type -> DeviceId
|
||||
1, // 5: Levelzero.GetDeviceTemperature:input_type -> DeviceId
|
||||
0, // 6: Levelzero.GetIntelIndices:input_type -> GetIntelIndicesMessage
|
||||
1, // 7: Levelzero.GetDeviceMemoryAmount:input_type -> DeviceId
|
||||
2, // 8: Levelzero.GetDeviceHealth:output_type -> DeviceHealth
|
||||
3, // 9: Levelzero.GetDeviceTemperature:output_type -> DeviceTemperature
|
||||
4, // 10: Levelzero.GetIntelIndices:output_type -> DeviceIndices
|
||||
5, // 11: Levelzero.GetDeviceMemoryAmount:output_type -> DeviceMemoryAmount
|
||||
8, // [8:12] is the sub-list for method output_type
|
||||
4, // [4:8] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_levelzero_proto_init() }
|
||||
func file_levelzero_proto_init() {
|
||||
if File_levelzero_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_levelzero_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetIntelIndicesMessage); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_levelzero_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DeviceId); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_levelzero_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DeviceHealth); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_levelzero_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DeviceTemperature); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_levelzero_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DeviceIndices); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_levelzero_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DeviceMemoryAmount); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_levelzero_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Error); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_levelzero_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_levelzero_proto_goTypes,
|
||||
DependencyIndexes: file_levelzero_proto_depIdxs,
|
||||
MessageInfos: file_levelzero_proto_msgTypes,
|
||||
}.Build()
|
||||
File_levelzero_proto = out.File
|
||||
file_levelzero_proto_rawDesc = nil
|
||||
file_levelzero_proto_goTypes = nil
|
||||
file_levelzero_proto_depIdxs = nil
|
||||
}
|
45
cmd/internal/levelzero/levelzero.proto
Normal file
45
cmd/internal/levelzero/levelzero.proto
Normal file
@ -0,0 +1,45 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "gpu.levelzero";
|
||||
|
||||
service Levelzero {
|
||||
rpc GetDeviceHealth(DeviceId) returns (DeviceHealth) {}
|
||||
rpc GetDeviceTemperature(DeviceId) returns (DeviceTemperature) {}
|
||||
rpc GetIntelIndices(GetIntelIndicesMessage) returns (DeviceIndices) {}
|
||||
rpc GetDeviceMemoryAmount(DeviceId) returns (DeviceMemoryAmount) {}
|
||||
}
|
||||
|
||||
message GetIntelIndicesMessage {}
|
||||
|
||||
message DeviceId {
|
||||
string bdfAddress = 1;
|
||||
}
|
||||
|
||||
message DeviceHealth {
|
||||
bool memory_ok = 1;
|
||||
bool bus_ok = 2;
|
||||
bool soc_ok = 3;
|
||||
Error error = 42;
|
||||
}
|
||||
|
||||
message DeviceTemperature {
|
||||
double global = 1;
|
||||
double gpu = 2;
|
||||
double memory = 3;
|
||||
Error error = 42;
|
||||
}
|
||||
|
||||
message DeviceIndices {
|
||||
repeated uint32 indices = 1;
|
||||
Error error = 42;
|
||||
}
|
||||
|
||||
message DeviceMemoryAmount {
|
||||
uint64 memory_size = 1;
|
||||
Error error = 42;
|
||||
}
|
||||
|
||||
message Error {
|
||||
string description = 1;
|
||||
uint32 errorcode = 2;
|
||||
}
|
227
cmd/internal/levelzero/levelzero_grpc.pb.go
Normal file
227
cmd/internal/levelzero/levelzero_grpc.pb.go
Normal file
@ -0,0 +1,227 @@
|
||||
// Copyright 2024 Intel Corporation. All Rights Reserved.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.12.4
|
||||
// source: levelzero.proto
|
||||
|
||||
package gpulevelzero
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// LevelzeroClient is the client API for Levelzero service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type LevelzeroClient interface {
|
||||
GetDeviceHealth(ctx context.Context, in *DeviceId, opts ...grpc.CallOption) (*DeviceHealth, error)
|
||||
GetDeviceTemperature(ctx context.Context, in *DeviceId, opts ...grpc.CallOption) (*DeviceTemperature, error)
|
||||
GetIntelIndices(ctx context.Context, in *GetIntelIndicesMessage, opts ...grpc.CallOption) (*DeviceIndices, error)
|
||||
GetDeviceMemoryAmount(ctx context.Context, in *DeviceId, opts ...grpc.CallOption) (*DeviceMemoryAmount, error)
|
||||
}
|
||||
|
||||
type levelzeroClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewLevelzeroClient(cc grpc.ClientConnInterface) LevelzeroClient {
|
||||
return &levelzeroClient{cc}
|
||||
}
|
||||
|
||||
func (c *levelzeroClient) GetDeviceHealth(ctx context.Context, in *DeviceId, opts ...grpc.CallOption) (*DeviceHealth, error) {
|
||||
out := new(DeviceHealth)
|
||||
err := c.cc.Invoke(ctx, "/Levelzero/GetDeviceHealth", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *levelzeroClient) GetDeviceTemperature(ctx context.Context, in *DeviceId, opts ...grpc.CallOption) (*DeviceTemperature, error) {
|
||||
out := new(DeviceTemperature)
|
||||
err := c.cc.Invoke(ctx, "/Levelzero/GetDeviceTemperature", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *levelzeroClient) GetIntelIndices(ctx context.Context, in *GetIntelIndicesMessage, opts ...grpc.CallOption) (*DeviceIndices, error) {
|
||||
out := new(DeviceIndices)
|
||||
err := c.cc.Invoke(ctx, "/Levelzero/GetIntelIndices", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *levelzeroClient) GetDeviceMemoryAmount(ctx context.Context, in *DeviceId, opts ...grpc.CallOption) (*DeviceMemoryAmount, error) {
|
||||
out := new(DeviceMemoryAmount)
|
||||
err := c.cc.Invoke(ctx, "/Levelzero/GetDeviceMemoryAmount", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// LevelzeroServer is the server API for Levelzero service.
|
||||
// All implementations must embed UnimplementedLevelzeroServer
|
||||
// for forward compatibility
|
||||
type LevelzeroServer interface {
|
||||
GetDeviceHealth(context.Context, *DeviceId) (*DeviceHealth, error)
|
||||
GetDeviceTemperature(context.Context, *DeviceId) (*DeviceTemperature, error)
|
||||
GetIntelIndices(context.Context, *GetIntelIndicesMessage) (*DeviceIndices, error)
|
||||
GetDeviceMemoryAmount(context.Context, *DeviceId) (*DeviceMemoryAmount, error)
|
||||
mustEmbedUnimplementedLevelzeroServer()
|
||||
}
|
||||
|
||||
// UnimplementedLevelzeroServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedLevelzeroServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedLevelzeroServer) GetDeviceHealth(context.Context, *DeviceId) (*DeviceHealth, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetDeviceHealth not implemented")
|
||||
}
|
||||
func (UnimplementedLevelzeroServer) GetDeviceTemperature(context.Context, *DeviceId) (*DeviceTemperature, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetDeviceTemperature not implemented")
|
||||
}
|
||||
func (UnimplementedLevelzeroServer) GetIntelIndices(context.Context, *GetIntelIndicesMessage) (*DeviceIndices, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetIntelIndices not implemented")
|
||||
}
|
||||
func (UnimplementedLevelzeroServer) GetDeviceMemoryAmount(context.Context, *DeviceId) (*DeviceMemoryAmount, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetDeviceMemoryAmount not implemented")
|
||||
}
|
||||
func (UnimplementedLevelzeroServer) mustEmbedUnimplementedLevelzeroServer() {}
|
||||
|
||||
// UnsafeLevelzeroServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to LevelzeroServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeLevelzeroServer interface {
|
||||
mustEmbedUnimplementedLevelzeroServer()
|
||||
}
|
||||
|
||||
func RegisterLevelzeroServer(s grpc.ServiceRegistrar, srv LevelzeroServer) {
|
||||
s.RegisterService(&Levelzero_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Levelzero_GetDeviceHealth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeviceId)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LevelzeroServer).GetDeviceHealth(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Levelzero/GetDeviceHealth",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LevelzeroServer).GetDeviceHealth(ctx, req.(*DeviceId))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Levelzero_GetDeviceTemperature_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeviceId)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LevelzeroServer).GetDeviceTemperature(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Levelzero/GetDeviceTemperature",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LevelzeroServer).GetDeviceTemperature(ctx, req.(*DeviceId))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Levelzero_GetIntelIndices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetIntelIndicesMessage)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LevelzeroServer).GetIntelIndices(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Levelzero/GetIntelIndices",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LevelzeroServer).GetIntelIndices(ctx, req.(*GetIntelIndicesMessage))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Levelzero_GetDeviceMemoryAmount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeviceId)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LevelzeroServer).GetDeviceMemoryAmount(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Levelzero/GetDeviceMemoryAmount",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LevelzeroServer).GetDeviceMemoryAmount(ctx, req.(*DeviceId))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Levelzero_ServiceDesc is the grpc.ServiceDesc for Levelzero service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Levelzero_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "Levelzero",
|
||||
HandlerType: (*LevelzeroServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetDeviceHealth",
|
||||
Handler: _Levelzero_GetDeviceHealth_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetDeviceTemperature",
|
||||
Handler: _Levelzero_GetDeviceTemperature_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetIntelIndices",
|
||||
Handler: _Levelzero_GetIntelIndices_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetDeviceMemoryAmount",
|
||||
Handler: _Levelzero_GetDeviceMemoryAmount_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "levelzero.proto",
|
||||
}
|
2
go.mod
2
go.mod
@ -16,6 +16,7 @@ require (
|
||||
golang.org/x/sys v0.25.0
|
||||
golang.org/x/text v0.18.0
|
||||
google.golang.org/grpc v1.66.2
|
||||
google.golang.org/protobuf v1.34.2
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.31.0
|
||||
k8s.io/apimachinery v0.31.0
|
||||
@ -115,7 +116,6 @@ require (
|
||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
|
Loading…
Reference in New Issue
Block a user