I would like to see compile_function_checked
and enqueue_function_checked
be marked as “deprecated” because compile_function and enqueue_function will implement the same functionality in some future version. (BUT, for the moment, please use the checked versions in the GPU programming tutorials for Mojo.)
Motivation: Mojo is a strongly typed language and the compiler detects almost all type mismatches. The GPU functions are an exception, where it is possible to pass the wrong argument type and screw up the results without any compiler warning.
My example is from a recent GPU exercise, where my results were screwed up because I had passed the literal 10.0
(Mojo Float64) as an argument where the GPU fn expected Float32
. It took me a couple of hours to detect this, because it hadn’t occurred to me that a compiler that warns about a missing full stop in a docstring would let me make such a mistake.
This kind of argument mismatch is detected in Mojo CPU code. (It’s also detected in CUDA code.) Sure, if I was programming in Python or JavaScript I would check all my arguments; but my mindset is different when I’m programming in Mojo.
So, can you please add whatever behind the scenes code duplication or whatever is necessary so compile_function
invokes the same checks as compile_function_checked
and the same when enqueueing? I doubt that there is a noticeable performance loss from checking the arguments when enqueueing a GPU fn
and it would make Mojo GPU programming simpler and less error-prone.