Skip to content

Conversation

@dmcdougall
Copy link

Description

This commit teaches OCCA to understand the OCCA_HIP_OVERRIDE_COMPILE_ARCH environment variable. If set, OCCA will ignore the arch set in the kernel properties and try to compile for the architecture provided in the environment variable.

This allows the user to have more control over what targets are JITted for. Usecases are for JITting for generic targets (see here) and for the (currently beta) amdgcnspirv target (see here).

Unfortunately, the amdgcnspirv target name doesn't start with "gfx", so I added a branch that checks for this case and treats it accordingly.

Comments, criticism, tomatoes, and hecklers are not only welcome but heavily encouraged.

@thilinarmtb
Copy link
Collaborator

thilinarmtb commented Jul 2, 2025

@dmcdougall : Seems like both CUDA and HIP both set the architecture compiler option. Wondering
if it is a good idea to rename the variable to OCCA_OVERRIDE_COMPILE_ARCH and let the backends which
set this compiler option query the env var (or better yet we update the kernelProperties based on the
env var and pass it around).

@kris-rowe
Copy link
Member

@dmcdougall Could you update this to target the development branch?

This commit teaches OCCA to understand the OCCA_HIP_OVERRIDE_COMPILE_ARCH
environment variable.  If set, OCCA will ignore the arch set in the kernel
properties and try to compile for the architecture provided in the environment
variable.

This allows the user to have more control over what targets are JITted for.
Usecases are for JITting for generic targets (see here:
llvm/llvm-project@f93aa51)
and for the (currently beta) amdgcnspirv target (see here:
https://rocm.docs.amd.com/projects/llvm-project/en/latest/conceptual/spirv.html#rocm-support-for-spir-v-beta).

Unfortunately, the amdgcnspirv target name doesn't start with "gfx", so I added
a branch that checks for this case and treats it accordingly.
@dmcdougall dmcdougall force-pushed the add_compile_arch_override branch from 1b12aa8 to e10068e Compare July 3, 2025 15:59
@dmcdougall dmcdougall changed the base branch from main to development July 3, 2025 15:59
@dmcdougall
Copy link
Author

Could you update this to target the development branch?

Rebased on top of development and now targets development.

@dmcdougall
Copy link
Author

Seems like both CUDA and HIP both set the architecture compiler option.

Honestly, I think any backend should be able to do this.

Wondering if it is a good idea to rename the variable to OCCA_OVERRIDE_COMPILE_ARCH and let the backends which
set this compiler option query the env var

I totally agree. I had initially wanted to do it this way, but didn't see a way for occa to consume the variable in a place that wasn't backend-specific.

(or better yet we update the kernelProperties based on the env var and pass it around).

Ah yes, maybe this is they way I should have done it to begin with.

@dmcdougall
Copy link
Author

Before I continue with implementing @thilinarmtb's feedback, is the general principle behind this idea acceptable?

@thilinarmtb
Copy link
Collaborator

Before I continue with implementing @thilinarmtb's feedback, is the general principle behind this idea acceptable?

I think this is a useful environment variable to have. Kris is on vacation so probably we will have to
wait till next week to know his opinion.

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

Successfully merging this pull request may close these issues.

3 participants