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

Adding declarations to llvmcall #11604

Merged
merged 9 commits into from
Nov 15, 2015
Merged

Adding declarations to llvmcall #11604

merged 9 commits into from
Nov 15, 2015

Conversation

vchuravy
Copy link
Member

@vchuravy vchuravy commented Jun 6, 2015

Rebased from #8740 via #11516 in response to #11603

This allows to hook up llvm intrinsics via llvmcall. This is necessary for the CUDA backend work and several people expressed that they have other usages in mind.

Ping @ihnorton @tkelman

Overview

This extension of llvmcall allows to pass declarations of intrinsics to llvmcall. As an example see:

function ceil(x::Float64)
    llvmcall(
        ("declare double @llvm.ceil.f64(double)",
         """%2 = call double @llvm.ceil.f64(double %0)
            ret double %2"""),
    Float64, Tuple{Float64}, x)
end

function ceilfloor(x::Float64)
    llvmcall(
        ("""declare double @llvm.ceil.f64(double)
            declare double @llvm.floor.f64(double)""",
         """%2 = call double @llvm.ceil.f64(double %0)
            %3 = call double @llvm.floor.f64(double %2)
            ret double %3"""),
    Float64, Tuple{Float64}, x)
end

llvmcall("""%2 = call double @llvm.ceil.f64(double %0)
ret double %2""", Float64, Tuple{Float64}, x)
end
@test_throws ErrorException undeclared_ceil(4.2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is apparently failing - does this functionality only work with LLVM 3.5+?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test seems to be quite finicky

Executing from the REPL:

julia> function undeclared_ceil(x::Float64)
           Base.llvmcall("""%2 = call double @llvm.ceil.f64(double %0)
               ret double %2""", Float64, Tuple{Float64}, x)
       end
undeclared_ceil (generic function with 1 method)

julia> undeclared_ceil(4.2)
ERROR: error compiling undeclared_ceil: Failed to parse LLVM Assembly: 
julia: <string>:3:18: error: use of undefined value '@llvm.ceil.f64'
%2 = call double @llvm.ceil.f64(double %0)
try 
         undeclared_ceil(4.3)
       catch err
         println(err)
       end
ErrorException("error compiling undeclared_ceil: Failed to parse LLVM Assembly: \njulia: <string>:3:18: error: use of undefined value '@llvm.ceil.f64'\n%2 = call double @llvm.ceil.f64(double %0)\n                 ^\n")
julia> Test.@test_throws ErrorException undeclared_ceil(4.3)

julia> Test.@test_throws ErrorException undeclared_ceil(4.3)
ERROR: test failed: undeclared_ceil(4.3) did not throw ErrorException
 in expression: undeclared_ceil(4.3)
 in error at error.jl:21
 in default_handler at test.jl:29
 in do_test_throws at test.jl:74
julia> try 
         undeclared_ceil(4.3)
       catch err
         println(typeof(err))
       end
ErrorException

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I noticed similar unpredictable behavior. Maybe the GC root will help?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That I really doubt... But maybe.....
The GC root needs to be fix though, unless I'm missing sth.

Edit: and by "the GC root" I meant the new add gc root commit

// if the IR is a tuple, we expect (declarations, ir)
if (jl_nfields(ir) != 2)
jl_error("Tuple as first argument to llvmcall must have exactly two children");
decl = jl_fieldref(ir,0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing GC root? (ir is overriden below and (new) line 628 is allocating)

@vchuravy
Copy link
Member Author

vchuravy commented Jun 7, 2015

There is one problem that I see and I don't for certain how to best solve it. Looking at the test failure wrt undeclared_ceil. One the first call to the function I get the expected error, but on the second one I get a valid return value:

julia> function undeclared_ceil(x::Float64)
           Base.llvmcall("""%2 = call double @llvm.ceil.f64(double %0)
               ret double %2""", Float64, Tuple{Float64}, x)
       end
undeclared_ceil (generic function with 1 method)

julia> undeclared_ceil(4.2)
ERROR: error compiling undeclared_ceil: Failed to parse LLVM Assembly: 
julia: <string>:3:18: error: use of undefined value '@llvm.ceil.f64'
%2 = call double @llvm.ceil.f64(double %0)
                 ^


julia> undeclared_ceil(4.2)
5.0

Even better calling a function with an undefined intrinsic throws the error and then adding a second function that also calls the intrinsic does not throws an error for the second function"

julia> function undeclared_ceil(x::Float64)
           Base.llvmcall("""%2 = call double @llvm.ceil.f64(double %0)
               ret double %2""", Float64, Tuple{Float64}, x)
       end
undeclared_ceil (generic function with 1 method)

julia> undeclared_ceil(4.1)
ERROR: error compiling undeclared_ceil: Failed to parse LLVM Assembly: 
julia: <string>:3:18: error: use of undefined value '@llvm.ceil.f64'
%2 = call double @llvm.ceil.f64(double %0)
                 ^


julia> function undeclared_ceil2(x::Float64)
           Base.llvmcall("""%2 = call double @llvm.ceil.f64(double %0)
               ret double %2""", Float64, Tuple{Float64}, x)
       end
undeclared_ceil2 (generic function with 1 method)

julia> undeclared_ceil2(4.1)
5.0

@vchuravy
Copy link
Member Author

vchuravy commented Jun 7, 2015

@maleadt added a comment about that case:

# KNOWN ISSUE: although the llvmcall in undeclare_ceil did error(), the LLVM
# module contains the generated IR referencing the ceil intrinsic. At some
# point, a declaration for that intrinsic is added, breaking any future
# llvmcall((conflicting declaration, ...), ...). Not an issue in LLVM 3.5+.

Suggestions are welcome

jl_error("Tuple as first argument to llvmcall must have exactly two children");
decl = jl_fieldref(ir,0);
ir = jl_fieldref(ir,1);
// Need GC root because of allocating call later
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces instead of tabs

@tkelman
Copy link
Contributor

tkelman commented Jun 7, 2015

I don't know whether there's any downside to enabling this feature, but if it would be useful to have now despite the tests doing funky things on LLVM 3.3, could we just comment out the unpredictable tests for now, and revisit after upgrading LLVM? #9336

@vchuravy
Copy link
Member Author

vchuravy commented Jun 7, 2015

I moved the gc root to the right place (hopefully) and commented out the wonky test.

@yuyichao
Copy link
Contributor

yuyichao commented Jun 7, 2015

@vchuravy Yup the GC root looks good to me now =).

@vchuravy
Copy link
Member Author

vchuravy commented Jun 7, 2015

Most of the added tests check the behaviour of llvm with regards to undefined or double defined intrinsics declarations, so for the time being I commented them out.

@vchuravy
Copy link
Member Author

vchuravy commented Jun 8, 2015

Instead of out-commenting I decided to future proof the test by adding a conditional on them. So when #9336 occurs we don't forget about the tests.

@vchuravy
Copy link
Member Author

vchuravy commented Jun 8, 2015

The Travis error on 64bit looks like a timeout to me, the llvmcall tests passed (Hurray). All test pass locally.

@vchuravy
Copy link
Member Author

vchuravy commented Jun 8, 2015

So I think this is ready for another look from somebody else. The last commit extends llvmcall to take multiple lines of declarations

@simonster simonster added the compiler:codegen Generation of LLVM IR and native code label Jun 8, 2015
@SimonDanisch
Copy link
Contributor

Compilation works, but there are test errors:

exception on 5:
Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: UNKNOWN at 0x7ff981ff8b9c -- RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)
RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)
Unwind_RaiseException at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libgcc_s_seh-1.dll (unknown line)
_cxa_throw at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
Znwy at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_generate_fptr at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
showerror at replutil.jl:91
jlcall_showerror_26418 at  (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at client.jl:88
jl_f_apply at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
with_output_color at util.jl:331
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
display_error at client.jl:86
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
run_work_thunk at multi.jl:608
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at task.jl:854
jl_unprotect_stack at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x6aa0abc1 -- utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_generate_fptr at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_svec_fill at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_gc_run_all_finalizers at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_atexit_hook at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_exit at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_throw_in_ctx at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
_chkstk at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RtlRaiseException at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RtlRaiseException at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)
Unwind_RaiseException at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libgcc_s_seh-1.dll (unknown line)
_cxa_throw at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
Znwy at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_generate_fptr at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
showerror at replutil.jl:91
jlcall_showerror_26418 at  (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at client.jl:88
jl_f_apply at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
with_output_color at util.jl:331
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
display_error at client.jl:86
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
run_work_thunk at multi.jl:608
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at task.jl:854
jl_unprotect_stack at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
        From worker 5:       * linalg/triangular   Worker 5 terminated.
ERROR (unhandled task failure): readcb: connection reset by peer (ECONNRESET)
 in remotecall_fetch at multi.jl:688
 in remotecall_fetch at multi.jl:693
 in anonymous at task.jl:1423
        From worker 3:       * linalg/cholesky      in 149.97 seconds
        From worker 4:       * linalg/lu            in 150.09 seconds
        From worker 2:       * linalg1              in 333.50 seconds
ERROR: LoadError: ProcessExitedException()
 in remotecall_fetch at multi.jl:688
 in remotecall_fetch at multi.jl:693
 in anonymous at task.jl:1423
while loading C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\share\julia\test\runtests.jl, in expression starting on line 5

@tkelman
Copy link
Contributor

tkelman commented Jun 9, 2015

@SimonDanisch what's your versioninfo() there? How was that built?

@SimonDanisch
Copy link
Contributor

Ah yeah, that was not very informative.
Windows + cygwin. Checked out JuliaGPU->vc/llvmcall + make (from fresh git clone).

Julia Version 0.4.0-dev+5241
Commit f8ce3bd (2015-06-08 14:37 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Do I need LLVM 3.5, or what?

@SimonDanisch
Copy link
Contributor

and I did make win-extras + make binary-dist and then installed it.

@tkelman
Copy link
Contributor

tkelman commented Jun 9, 2015

Thanks, I'll see if I can reproduce. Might be Haswell-specific?

@vchuravy
Copy link
Member Author

@SimonDanisch could you check out dff768a and see if the error is persistent there? That is the commit from which vc/llvmcall is branched off.

I would like to add some documentation for llvmcall In which section should that best go?
@Keno, since you wrote the original version, do you have some ideas on documentation?

@tkelman
Copy link
Contributor

tkelman commented Jun 10, 2015

ref #10760

@vchuravy vchuravy mentioned this pull request Jun 10, 2015
@SimonDanisch
Copy link
Contributor

julia> versioninfo()
Julia Version 0.4.0-dev+5235
Commit dff768a* (2015-06-06 12:56 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Looks quite similar:

C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin>julia.exe C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\share\julia\test\runtests.jl al
        From worker 5:       * linalg4              in  17.21 seconds
        From worker 5:       * linalg/lapack        in  24.04 seconds
        From worker 4:       * linalg3              in  48.03 seconds
        From worker 4:       * linalg/tridiag       in   9.33 seconds
        From worker 3:       * linalg2              in  64.73 seconds
        From worker 4:       * linalg/bidiag        in  20.47 seconds
        From worker 3:       * linalg/diagonal      in  20.77 seconds
        From worker 3:       * linalg/givens        in   2.71 seconds
        From worker 4:       * linalg/pinv          in  11.78 seconds
        From worker 3:       * linalg/cholesky      in  45.25 seconds
        From worker 4:       * linalg/lu            in  44.96 seconds
        From worker 2:       * linalg1              in 138.16 seconds
        From worker 3:       * linalg/symmetric     in   9.31 seconds
        From worker 3:       * keywordargs          in   2.12 seconds
exception on 4:
Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: UNKNOWN at 0x7fff2d268b9c -- RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)
UNKNOWNUnwind_RaiseException at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libgcc_s_seh-1.dll (unknown line)
 at 0x7fff2d268b9c -- _cxa_throw at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)
Znwy at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
Unwind_RaiseException at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libgcc_s_seh-1.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
_cxa_throw at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
jl_static_eval at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
Znwy at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
jl_static_eval at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_compile at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
do_test at test.jl:49
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_generate_fptr at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_interpret_toplevel_expr at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_interpret_toplevel_thunk_with at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
display_error at client.jl:86
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_eval_with_compiler_p at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
run_work_thunk at multi.jl:608
jl_parse_eval_all at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_ at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at task.jl:854
unknown function (ip: 1691279766)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_unprotect_stack at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
runtests at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\share\julia\test\testdefs.jl:197
jlcall_runtests_21263 at  (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_f_apply at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at multi.jl:854
run_work_thunk at multi.jl:605
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at task.jl:854
jl_unprotect_stack at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x6b05b527 -- utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x6b49194c -- utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_dump_llvm_value at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_static_eval at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_compile at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_generate_fptr at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_svec_fill at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_gc_run_all_finalizers at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_atexit_hook at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_exit at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_throw_in_ctx at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
_chkstk at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RtlRaiseException at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RtlRaiseException at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)
Unwind_RaiseException at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libgcc_s_seh-1.dll (unknown line)
_cxa_throw at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
Znwy at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_svec_fill at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_gc_run_all_finalizers at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_static_eval at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_static_eval at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
        From worker 2:       * core                jl_atexit_hook at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (u
jl_exit at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_throw_in_ctx at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
_chkstk at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RtlRaiseException at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RtlRaiseException at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
RaiseException at C:\WINDOWS\system32\KERNELBASE.dll (unknown line)
Unwind_RaiseException at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libgcc_s_seh-1.dll (unknown line)
_cxa_throw at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
Znwy at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libstdc++-6.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
utf8proc_NFKC at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_generate_fptr at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
display_error at client.jl:86
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
run_work_thunk at multi.jl:608
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at task.jl:854
jl_unprotect_stack at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_and_lookup at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_compile at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_trampoline at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
do_test at test.jl:49
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_interpret_toplevel_expr at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_interpret_toplevel_thunk_with at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_eval_with_compiler_p at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_parse_eval_all at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_load_ at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
unknown function (ip: 1691279766)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
runtests at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\share\julia\test\testdefs.jl:197
jlcall_runtests_21263 at  (unknown line)
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
jl_f_apply at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at multi.jl:854
run_work_thunk at multi.jl:605
jl_apply_generic at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
anonymous at task.jl:854
jl_unprotect_stack at C:\Users\Sim\AppData\Local\Julia-0.4.0-gpu\bin\libjulia.dll (unknown line)
Worker 2 terminated.ERROR (unhandled task failure): InexactError()
 in _uv_hook_return_spawn at process.jl:238
        From worker 5:       * linalg/triangular    in 131.21 seconds

@vchuravy
Copy link
Member Author

@SimonDanisch thanks for checking that :) That means it is not the fault of this PR. Could you check against current master and if it persists open an issue about it? If it goes away fixing it here should be then as simple as a rebase.

@vchuravy vchuravy changed the title [RFC] llvmcall [RFC] Adding declarations to llvmcall Jun 10, 2015
@SimonDanisch
Copy link
Contributor

I'm on it ;) compilation is just always a little slow...

@SimonDanisch
Copy link
Contributor

Okay... So it first gave me an OutOfMemoryException(), but after a restart with fewer processes master completed successfully.

Julia Version 0.4.0-dev+5293
Commit 608fc91* (2015-06-10 09:21 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

@vchuravy vchuravy changed the title [RFC] Adding declarations to llvmcall Adding declarations to llvmcall Jun 11, 2015
The test that checks llvm behaviour for undefined intrinsics does not
work on llvm 3.3. It works(tm) under llvm 3.5+.
getNamedValue expects getNamedValue("llvm.floor.f64") for "declare
double @llvm.floor.f64(double)"
@vchuravy
Copy link
Member Author

vchuravy commented Nov 2, 2015

@ViralBShah @hayd Rebased.

Since we now have documentation for llvmcall I will write additional documentation for this.

@vchuravy
Copy link
Member Author

vchuravy commented Nov 2, 2015

The failing build seems to be a homebrew issue.

Error: No such file or directory - /usr/local/Cellar/oniguruma/5.9.6/share/emacs/site-lisp/oniguruma

@tkelman
Copy link
Contributor

tkelman commented Nov 2, 2015

Looked like a download failure, restarted the build and it passed. This LGTM if other people think it's safe.

@vchuravy
Copy link
Member Author

vchuravy commented Nov 3, 2015

So I added a short documentation for the declarations, I hope I got the format right.

@vchuravy
Copy link
Member Author

vchuravy commented Nov 8, 2015

@Keno what do you think?

@tkelman
Copy link
Contributor

tkelman commented Nov 13, 2015

@Keno @vtjnash can we merge this?

@tkelman
Copy link
Contributor

tkelman commented Nov 15, 2015

Alright, tired of waiting for review from unresponsive code owners on this. If it causes any problems they can be addressed going forward.

tkelman added a commit that referenced this pull request Nov 15, 2015
Adding declarations to llvmcall
@tkelman tkelman merged commit 1ce01b1 into JuliaLang:master Nov 15, 2015
@yuyichao yuyichao deleted the vc/llvmcall branch November 15, 2015 13:43
@vchuravy
Copy link
Member Author

Thank you all for staying on this with me :)

@tkelman
Copy link
Contributor

tkelman commented Nov 15, 2015

#11516 has the potential to be a pretty big deal, so thank you for seeing it through and making it happen. What's next, #9423?

@vchuravy
Copy link
Member Author

Yeah that is next, but it will need a heavy rebase due to the codegen
changes.

On Sun, 15 Nov 2015 at 23:27 Tony Kelman notifications@github.com wrote:

#11516 #11516 has the potential
to be a pretty big deal, so thank you for seeing it through and making it
happen. What's next, #9423 #9423?


Reply to this email directly or view it on GitHub
#11604 (comment).

@maleadt
Copy link
Member

maleadt commented Nov 16, 2015

Thanks for getting this merged! I only now noticed the declaration extraction, why exactly do we do that? It also doesn't seem compatible with global variable declarations (a la @foo = bar), but is just a matter of adjusting the parsing.

@vchuravy
Copy link
Member Author

I added the function name parsing to prevent adding already know declarations to the module, which would lead to an error (on llvm versions where Julia uses one module for everything). Since llvmcall is only meant for functions, I am unsure if adding more global state, is a good idea. What do you need global variables for? And would that work if each function has its own module?

@maleadt
Copy link
Member

maleadt commented Nov 17, 2015

Previously, we just added the entire declaration string into the llvmcallDecls, which also prevented duplicate declarations. I'm just unsure why parsing the declaration name is necessary, splitting on endline boundaries seems sufficient to me.

Concerning global variables, these just behave like declarations (only use them after being added once to the module). I'm currently using it for hackish shared memory support (decl: @shmem = ...(), ir: load/store(@shmem, ...)) but I'm sure there's more legit use cases with them.

@vchuravy
Copy link
Member Author

Hm the problem was that we would insert these declarations into a module where they already are defined. So as an example code like

julia/test/llvmcall.jl

Lines 96 to 117 in 8c23dc8

function doubly_declared_floor(x::Float64)
llvmcall(
("""declare double @llvm.floor.f64(double)""",
"""%2 = call double @llvm.floor.f64(double %0)
ret double %2"""),
Float64, Tuple{Float64}, x+1)-1
end
@test_approx_eq doubly_declared_floor(4.2) 4.
function doubly_declared2_trunc(x::Float64)
a = llvmcall(
("""declare double @llvm.trunc.f64(double)""",
"""%2 = call double @llvm.trunc.f64(double %0)
ret double %2"""),
Float64, Tuple{Float64}, x)
b = llvmcall(
("""declare double @llvm.trunc.f64(double)""",
"""%2 = call double @llvm.trunc.f64(double %0)
ret double %2"""),
Float64, Tuple{Float64}, x+1)-1
a + b
end
would fail, because both declarations would end up in the same llvm module.

@maleadt
Copy link
Member

maleadt commented Nov 17, 2015

But the declaration string for declared_floor equals that of doubly_declared_floor, so this should be caught? I'll have a stab at it, having good tests makes this easy to test :-) If not, I guess tweaking the declaration parsing should fix the global variable use case. I'll add a test for that too then.

@vchuravy
Copy link
Member Author

Yes if the declaration came in via llvmcall it will be caught, but not if it came in via one of the base intrinsics (I might be miss remembering things)

@maleadt
Copy link
Member

maleadt commented Nov 17, 2015

Problem is, the intrinsics defined outside of llvmcall will not be present in the llvmcalldecls set, so we can't check against them. In other words, it would still result in a double declaration.
This does not hold for the base intrinsics though, because these seem to be added through getDeclaration(llvm::Intrinsic), which doesn't physically add a declare statement to the module.

@vchuravy
Copy link
Member Author

Yes, that's why we need to parse them so we can check if they are already present in the module https://github.com/JuliaGPU/julia/commit/2ca11b6f5d39b4bf7d36aeb157871a2d663039df#diff-be60d844ffde1319a02946d17c472e46R629

@maleadt
Copy link
Member

maleadt commented Nov 17, 2015

Ah completely missed that, sorry for the noise. I'll update the declaration parsing then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants