Skip to content

Commit

Permalink
fix lint & compile
Browse files Browse the repository at this point in the history
  • Loading branch information
zhewang1-intc committed Mar 19, 2024
1 parent d815e78 commit 1b4fe85
Showing 1 changed file with 5 additions and 37 deletions.
42 changes: 5 additions & 37 deletions gpu/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ var OneapiLinuxGlobs = []string{
"/usr/lib*/libze_intel_gpu.so*",
}

var OneapiLinuxGlobs = []string{
"/usr/lib/x86_64-linux-gnu/libze_intel_gpu.so*",
"/usr/lib*/libze_intel_gpu.so*",
}

// Note: gpuMutex must already be held
func initGPUHandles() {

Expand Down Expand Up @@ -110,16 +105,6 @@ func initGPUHandles() {
return
}
}

oneapiLibPaths := FindGPULibs(oneapiMgmtName, oneapiMgmtPatterns)
if len(oneapiLibPaths) > 0 {
oneapi := LoadOneapiMgmt(oneapiLibPaths)
if oneapi != nil {
slog.Info("Intel GPU detected")
gpuHandles.oneapi = oneapi
return
}
}
}

func GetGPUInfo() GpuInfo {
Expand Down Expand Up @@ -180,11 +165,6 @@ func GetGPUInfo() GpuInfo {
}
resp.Library = "oneapi"
}
} else {
AMDGetGPUInfo(&resp)
if resp.Library != "" {
return resp
}
} else if gpuHandles.oneapi != nil && (cpuVariant != "" || runtime.GOARCH != "amd64") {

Check failure on line 168 in gpu/gpu.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest, amd64)

SA4014: this condition occurs multiple times in this if/else if chain (staticcheck)
C.oneapi_check_vram(*gpuHandles.oneapi, &memInfo)
if memInfo.err != nil {
Expand All @@ -207,6 +187,11 @@ func GetGPUInfo() GpuInfo {
}
resp.Library = "oneapi"
}
} else {
AMDGetGPUInfo(&resp)
if resp.Library != "" {
return resp
}
}
if resp.Library == "" {
C.cpu_check_ram(&memInfo)
Expand Down Expand Up @@ -352,23 +337,6 @@ func LoadOneapiMgmt(rocmLibPaths []string) *C.oneapi_handle_t {
return nil
}

func LoadOneapiMgmt(rocmLibPaths []string) *C.oneapi_handle_t {
var resp C.oneapi_init_resp_t
resp.oh.verbose = getVerboseState()
for _, libPath := range rocmLibPaths {
lib := C.CString(libPath)
defer C.free(unsafe.Pointer(lib))
C.oneapi_init(lib, &resp)
if resp.err != nil {
slog.Info(fmt.Sprintf("Unable to load oneAPI management library %s: %s", libPath, C.GoString(resp.err)))
C.free(unsafe.Pointer(resp.err))
} else {
return &resp.oh
}
}
return nil
}

func getVerboseState() C.uint16_t {
if debug := os.Getenv("OLLAMA_DEBUG"); debug != "" {
return C.uint16_t(1)
Expand Down

0 comments on commit 1b4fe85

Please sign in to comment.