From 34ef8bbcaa507368a630f5a4ac297e1d40366754 Mon Sep 17 00:00:00 2001 From: Mason Protter Date: Thu, 16 Nov 2023 09:18:58 +0100 Subject: [PATCH] Add some device overrides for Bumper.jl (#149) * Update quirks.jl * Update Project.toml --- Project.toml | 2 +- src/quirks.jl | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 6be72b4c..4be53224 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "StaticCompiler" uuid = "81625895-6c0f-48fc-b932-11a18313743c" authors = ["Tom Short and contributors"] -version = "0.6.1" +version = "0.6.2" [deps] Clang_jll = "0ee61d77-7f21-5576-8119-9fcc46b10100" diff --git a/src/quirks.jl b/src/quirks.jl index ffa25ac0..65ebc7b4 100644 --- a/src/quirks.jl +++ b/src/quirks.jl @@ -44,3 +44,15 @@ end # trig.jl @device_override @noinline Base.Math.sincos_domain_error(x) = @print_and_throw c"sincos(x) is only defined for finite x." + +@static if isdefined(StaticTools, :Bumper) + Bumper = StaticTools.Bumper + @device_override @noinline Bumper.AllocBufferImpl.oom_error() = + @print_and_throw c"alloc: Buffer out of memory. This might be a sign of a memory leak." + @device_override @noinline Bumper.Internals.esc_err() = + @print_and_throw c"Tried to return a PtrArray from a `no_escape` block. If you really want to do this, evaluate Bumper.allow_ptrarray_to_escape() = true" + + # Just to make the compiler's life a little easier, let's not make it fetch and elide the current task + # since tasks don't actually exist on-device. + @device_override Bumper.Internals.get_task() = 0 +end