Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect CPU limitations in runtime (AVX, F16C, NEON, etc.) #182

Open
Macoron opened this issue May 21, 2023 · 0 comments
Open

Detect CPU limitations in runtime (AVX, F16C, NEON, etc.) #182

Macoron opened this issue May 21, 2023 · 0 comments

Comments

@Macoron
Copy link

Macoron commented May 21, 2023

I've been working for a several packaged projects using ggml and received reports that app crashes on different end-users machines. From gathered data this is probably because compiled dll that is packaged with app contains AVX commands, which might not be supported on end-user CPU or OS.

I propose that we can add runtime checks of what end-users CPU actually capable of (AVX, F16C support, etc). We can add a new function like is_ggml_supported() which will return false if any required commands extension is missing. This could be handled by app to change it behavior or just print that device isn't supported, not just crash silently.

The good example of how to implement all this checks is here:
https://github.com/Mysticial/FeatureDetector

The C API might look something like this:

struct cpu_info{
    //  OS Features
    bool OS_AVX;
    bool OS_AVX512;

    //  SIMD: 256-bit
    bool HW_AVX;
    bool HW_AVX2;
    ...
} info;

bool is_ggml_supported(){
#if defined(__AVX__)
    if (!info.OS_AVX || !info.HW_AVX)
        return false;
#endif
#if defined(__AVX2__)
    if (!info.OS_AVX || !info.HW_AVX2)
        return false;
#endif
    return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant