Revision f442e4230a41d0d40f81346c1707f946f743cbcf authored by Jeff Bezanson on 09 June 2021, 02:51:34 UTC, committed by GitHub on 09 June 2021, 02:51:34 UTC
This PR implements a way to keep tables of methods that are
not part of the internal method table, but still participate
in the special support we have for keeping tables of methods,
in particular unification through precompilation and efficient
lookup. The intended design use case is to allow for method overlay
tables for various non-CPU backends (e.g. GPU and TPU). These
backends would like to modify basic function like `sin` to
perform better on the device in question (or in the case of TPU
to define them over non-LLVM intrinsics).

It is worth noting that this PR only gives the ability to keep
these tables of methods. It assigns no particular meaning to them
and the runtime (and regular inference) do not look at them.
They are designed as an implementation detail for external
compilers and similar tools.

 # Demo

```julia
julia> using Base.Experimental: @overlay, @MethodTable

julia> @MethodTable(mt)
 # 0 methods:

julia> @overlay mt function sin(x::Float64)
           1
       end

julia> @overlay mt function cos(x::Float64)
           1
       end

julia> mt
 # 2 methods:
[1] cos(x::Float64) in Main at REPL[5]:1
[2] sin(x::Float64) in Main at REPL[4]:1

julia> Base._methods_by_ftype(Tuple{typeof(sin), Float64}, mt, 1, typemax(UInt))
1-element Vector{Any}:
 Core.MethodMatch(Tuple{typeof(sin), Float64}, svec(), sin(x::Float64) in Main at REPL[4]:1, true)

julia> Base._methods_by_ftype(Tuple{typeof(sin), Float64}, 1, typemax(UInt))
1-element Vector{Any}:
 Core.MethodMatch(Tuple{typeof(sin), Float64}, svec(Float64), sin(x::T) where T<:Union{Float32, Float64} in Base.Math at special/trig.jl:29, true)
```

Co-authored-by: Tim Besard <tim.besard@gmail.com>
Co-authored-by: Julian P Samaroo <jpsamaroo@jpsamaroo.me>
Co-authored-by: Keno Fischer <keno@juliacomputing.com>
1 parent 0e3276c
History
File Mode Size
checksums
patches
tools
valgrind
.gitignore -rw-r--r-- 26 bytes
Makefile -rw-r--r-- 5.4 KB
Versions.make -rw-r--r-- 2.7 KB
blastrampoline.mk -rw-r--r-- 1.4 KB
blastrampoline.version -rw-r--r-- 90 bytes
csl.mk -rw-r--r-- 2.7 KB
curl.mk -rw-r--r-- 3.3 KB
dsfmt.mk -rw-r--r-- 2.2 KB
gfortblas.alias -rw-r--r-- 706 bytes
gfortblas.c -rw-r--r-- 4.4 KB
gmp.mk -rw-r--r-- 2.4 KB
libdSFMT.def -rw-r--r-- 778 bytes
libgit2.mk -rw-r--r-- 4.7 KB
libgit2.version -rw-r--r-- 76 bytes
libssh2.mk -rw-r--r-- 2.1 KB
libssh2.version -rw-r--r-- 83 bytes
libsuitesparse.mk -rw-r--r-- 4.9 KB
libuv.mk -rw-r--r-- 1.9 KB
libuv.version -rw-r--r-- 82 bytes
libwhich.mk -rw-r--r-- 1.2 KB
libwhich.version -rw-r--r-- 78 bytes
llvm-options.mk -rw-r--r-- 907 bytes
llvm-ver.make -rw-r--r-- 359 bytes
llvm.mk -rw-r--r-- 21.9 KB
mbedtls.mk -rw-r--r-- 3.9 KB
mpfr.mk -rw-r--r-- 2.6 KB
nghttp2.mk -rw-r--r-- 2.0 KB
objconv.mk -rw-r--r-- 1.0 KB
openblas.mk -rw-r--r-- 8.6 KB
openblas.version -rw-r--r-- 79 bytes
openlibm.mk -rw-r--r-- 1.3 KB
openlibm.version -rw-r--r-- 78 bytes
p7zip.mk -rw-r--r-- 2.6 KB
patchelf.mk -rw-r--r-- 1.9 KB
pcre.mk -rw-r--r-- 2.8 KB
unwind.mk -rw-r--r-- 5.7 KB
utf8proc.mk -rw-r--r-- 1.5 KB
utf8proc.version -rw-r--r-- 78 bytes
zlib.mk -rw-r--r-- 1.3 KB
zlib.version -rw-r--r-- 71 bytes

back to top