Skip to content

Polyfill support #425

@kevmo314

Description

@kevmo314

I'm not sure if this is within scope of avo, but does there exist any polyfill-like support for converting, eg AVX512 instructions to AVX2?

For example, I am (actually) a new asm developer and I recently spent an hour trying to figure out why VMULPS.BCST(Imm(...), x y) resulted in a SIGILL before I realized that the m32bcst version is only available on AVX512F/AVX512VL.

I then thought about the compilation target and while my CPU doesn't support AVX512F, I'd like to be able to generate an AVX512F version of code that would conditionally execute for processors that do support it and fall back to the AVX2 version (VBROADCASTSS first and then VMULPS) for those that don't.

I can do this manually by conditionally generating the instructions but was wondering if there's a more pragmatic solution, similar to polyfilling, or maybe a high level directive similar to @supports? Maybe the API I'm envisioning is something like:

ctx := NewContext()
ctx.VMULPS_BCST(...)
if ctx.IsSupported(<some user-provided capabilities set>) {
  globalCtx.Add(ctx)
} else {
  // fallback implementation
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions