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

Validate inputs and outputs earlier. #390

Merged
merged 2 commits into from
Feb 10, 2023
Merged

Validate inputs and outputs earlier. #390

merged 2 commits into from
Feb 10, 2023

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Feb 10, 2023

Metal's LLVM post-processing inspects arguments (as does CUDA.jl's), so we need to make sure there's no invalid stuff in there. Currently, we were only running the code instance validation during emit_asm, instead make it happen as early as possible, during emit_julia.

  Got exception outside of a @test
  LoadError: Type Array does not have a definite size.
  Stacktrace:
    [1] sizeof(x::Type)
      @ Base ./essentials.jl:473
    [2] add_argument_metadata!(job::GPUCompiler.CompilerJob, mod::LLVM.Module, entry::LLVM.Function)
      @ GPUCompiler ~/Julia/pkg/GPUCompiler/src/metal.jl:612
    [3] finish_ir!(job::GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget}, mod::LLVM.Module, entry::LLVM.Function)
      @ GPUCompiler ~/Julia/pkg/GPUCompiler/src/metal.jl:108
    [4] macro expansion
      @ ~/Julia/pkg/GPUCompiler/src/driver.jl:400 [inlined]
    [5] macro expansion
      @ ~/Julia/depot/packages/TimerOutputs/LHjFw/src/TimerOutput.jl:253 [inlined]
    [6] macro expansion
      @ ~/Julia/pkg/GPUCompiler/src/driver.jl:340 [inlined]
    [7] emit_llvm(job::GPUCompiler.CompilerJob, method_instance::Any; libraries::Bool, deferred_codegen::Bool, optimize::Bool, cleanup::Bool, only_entry::Bool, ctx::LLVM.Context)
      @ GPUCompiler ~/Julia/pkg/GPUCompiler/src/utils.jl:83
    [8] mtlfunction_compile(job::GPUCompiler.CompilerJob, ctx::LLVM.Context)
      @ Metal ~/Julia/pkg/Metal/src/compiler/execution.jl:166

Without optimization it's unlikely the IR will be valid.
@maleadt
Copy link
Member Author

maleadt commented Feb 10, 2023

Enzyme.jl failure unrelated.

@maleadt maleadt merged commit 15494f3 into master Feb 10, 2023
@maleadt maleadt deleted the tb/validate_early branch February 10, 2023 16:50
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.

2 participants