Error: failed to run the pass manager for offload functions

Hi,

I’m learning Mojo using a MacBook pro with M1 and working my way through the examples. I’ve just started this one; Get started with GPU programming | Modular

(pretty basic I know!)

The first step works fine:

mojo vector_addition.mojo

Found GPU: Apple M1 Max

However, creating a kernel fails to compile. I’ve reduced the code to this:

from gpu.host import DeviceContext

from gpu.id import block_idx, thread_idx

from sys import has_accelerator

fn print_threads():

“”“Print thread IDs.”“”

print(“Block index: [”,

block_idx.x,

“]\tThread index: [”,

thread_idx.x,

“]”

)

def main():

ctx = DeviceContext()

ctx.enqueue_function[print_threads](grid_dim=2, block_dim=64)

adding the cix.enqueue_function call and compiling gives the following errors:

% mojo vector_addition.mojo

gpu-intro/vector_addition.mojo:1:1: error: failed to run the pass manager for offload functions

from gpu.host import DeviceContext

^

gpu-intro/vector_addition.mojo:8:10: error: call expansion failed

print(“Block index: [”,

^

open-source/max/mojo/stdlib/stdlib/io/io.mojo:366:4: note: function instantiation failed

open-source/max/mojo/stdlib/stdlib/io/io.mojo:432:18: note: call expansion failed

open-source/max/mojo/stdlib/stdlib/sys/info.mojo:78:14: note: call expansion failed

open-source/max/mojo/stdlib/stdlib/builtin/constrained.mojo:58:6: note: constraint failed: Current compilation target does not support operation: print. Note:

mojo: error: failed to run the pass manager

No idea where to start with this…

All help appreciated!

Thanks

Pip

That’s the key statement in the error message. We haven’t yet built out all the operations to provide complete coverage of all GPU programming tasks on Apple Silicon GPUs yet, and support for print and debug_assert functions are still on our to-do list. We have a rough task list of items to be worked on in our announcement post for Apple Silicon GPU support, and I’ve been trying to keep that up to date as we fix or add new capabilities.

I can try to follow up once we do get print() support added on Apple Silicon GPUs. The calculation itself should work, but printing the threads may need to wait until that function is ready.

2 Likes

Thanks Brad

I should have read that error more closely- it says what it’s missing!!

Thank you very much, it’s great that Apple Silicon GPUs will gradually be in Tier 1 in the future.