bug#63986: Julia is very slow

2023-06-23 Thread Ludovic Courtès
Hi!

Simon Tournier  skribis:

> + ,@(if (target-x86-64?)
> + `("USE_BLAS64=1"
> +   "LIBBLAS=-lopenblas_ilp64"
> +   "LIBBLASNAME=libopenblas_ilp64")
> + `("LIBBLAS=-lopenblas"
> +   "LIBBLASNAME=libopenblas"))
>  
>   (string-append "UTF8PROC_INC="
>  (assoc-ref %build-inputs "utf8proc")
> @@ -513,7 +517,9 @@ (define-public julia
> ("llvm" ,llvm-julia)
> ("mbedtls-apache" ,mbedtls-apache)
> ("mpfr" ,mpfr)
> -   ("openblas" ,openblas)
> +   ,@(if (target-x86-64?)
> + `(("openblas" ,openblas-ilp64))
> + `(("openblas" ,openblas)))

Should it be ‘target-64bit?’ instead?

Thumbs up for finding the solution!

Ludo’.





bug#63986: Julia is very slow

2023-06-23 Thread Efraim Flashner
On Fri, Jun 23, 2023 at 11:09:44AM +0200, Ludovic Courtès wrote:
> Hi!
> 
> Simon Tournier  skribis:
> 
> > + ,@(if (target-x86-64?)
> > + `("USE_BLAS64=1"
> > +   "LIBBLAS=-lopenblas_ilp64"
> > +   "LIBBLASNAME=libopenblas_ilp64")
> > + `("LIBBLAS=-lopenblas"
> > +   "LIBBLASNAME=libopenblas"))
> >  
> >   (string-append "UTF8PROC_INC="
> >  (assoc-ref %build-inputs "utf8proc")
> > @@ -513,7 +517,9 @@ (define-public julia
> > ("llvm" ,llvm-julia)
> > ("mbedtls-apache" ,mbedtls-apache)
> > ("mpfr" ,mpfr)
> > -   ("openblas" ,openblas)
> > +   ,@(if (target-x86-64?)
> > + `(("openblas" ,openblas-ilp64))
> > + `(("openblas" ,openblas)))
> 
> Should it be ‘target-64bit?’ instead?

It should be, but julia fails the precompile stage with openblas-ilp64

Precompilation complete. Summary:
Total ─── 1006.632176 seconds
Generation ── 690.274180 seconds 68.5726%
Execution ─── 316.357997 seconds 31.4274%

signal (15): Terminated
in expression starting at none:0
unknown function (ip: 0xf4d81b24)
unknown function (ip: 0xf4ed10bb)
unknown function (ip: 0xf4eda16f)
_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE at 
/gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
(unknown line)
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at 
/gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
(unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at 
/gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
(unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at 
/gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
(unknown line)
operator() at 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/aotcompile.cpp:580 [inlined]
jl_dump_native_impl at 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/aotcompile.cpp:592
jl_write_compiler_output at 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/precompile.c:94
ijl_atexit_hook at /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/init.c:207
jl_repl_entrypoint at 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/jlapi.c:720
main at /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/cli/loader_exe.c:59
__libc_start_call_main at 
/gnu/store/a19xbynxc3sg25xpkwmx7g0mdl7g31hx-glibc-2.35/lib/libc.so.6 (unknown 
line)
__libc_start_main at 
/gnu/store/a19xbynxc3sg25xpkwmx7g0mdl7g31hx-glibc-2.35/lib/libc.so.6 (unknown 
line)
_start at /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/bin/julia (unknown 
line)
unknown function (ip: (nil))
Allocations: 145655328 (Pool: 145582643; Big: 72685); GC: 120
*** This error is usually fixed by running `make clean`. If the error persists, 
try `make cleanall`. ***
make[1]: *** [sysimage.mk:89: 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/lib/julia/sys-o.a] Error 1
make[1]: Leaving directory '/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3'
make: *** [Makefile:88: julia-sysimg-release] Error 2

> Thumbs up for finding the solution!
> 
> Ludo’.

-- 
Efraim Flashner  רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted


signature.asc
Description: PGP signature


bug#63986: Julia is very slow

2023-06-23 Thread Simon Tournier
Hi,

On Fri, 23 Jun 2023 at 12:16, Efraim Flashner  wrote:

>> Should it be ‘target-64bit?’ instead?
>
> It should be, but julia fails the precompile stage with openblas-ilp64

Well, I picked target-x86-64? because the recipe contains,

 ,@(if (target-aarch64?)
 `("USE_BLAS64=0")
 '())

so using target-64bit? would apply USE_BLAS64=1 to aarch64 when it was
not.  Well, since I know few about this architecture, I have tried to
keep the way it was.  Somehow, I have no opinion about what is best. :-)


Cheers,
simon






bug#63986: Julia is very slow

2023-06-23 Thread Simon Tournier
Hi Efraim,

On Thu, 22 Jun 2023 at 23:13, Efraim Flashner  wrote:

> - ,@(if (target-aarch64?)
> - `("USE_BLAS64=0")
> - '())

[...]

> + ,@(if (target-64bit?)
> + `("USE_BLAS64=1"

Well, I do not know but using this change USE_BLAS64=1 will be applied
to aarch64 when it was specifically not previously.  Is it expected?

> diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
> index b650b71f3b..deeffb67ae 100644
> --- a/gnu/packages/python-xyz.scm
> +++ b/gnu/packages/python-xyz.scm
> @@ -6953,19 +6953,36 @@ (define-public python-numpy

This change leads to a large rebuild.  Therefore, it should go first to
a dedicated branch, no?

Cheers,
simon





bug#63986: Julia is very slow

2023-06-23 Thread Simon Tournier
Hi Efraim,

On Fri, 23 Jun 2023 at 12:16, Efraim Flashner  wrote:

> It should be, but julia fails the precompile stage with openblas-ilp64
>
> Precompilation complete. Summary:
> Total ─── 1006.632176 seconds
> Generation ── 690.274180 seconds 68.5726%
> Execution ─── 316.357997 seconds 31.4274%
>
> signal (15): Terminated
> in expression starting at none:0
> unknown function (ip: 0xf4d81b24)
> unknown function (ip: 0xf4ed10bb)
> unknown function (ip: 0xf4eda16f)
> _ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE at 
> /gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
> (unknown line)
> _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at 
> /gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
> (unknown line)
> _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at 
> /gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
> (unknown line)
> _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at 
> /gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
> (unknown line)
> operator() at 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/aotcompile.cpp:580 [inlined]
> jl_dump_native_impl at 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/aotcompile.cpp:592
> jl_write_compiler_output at 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/precompile.c:94
> ijl_atexit_hook at 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/init.c:207
> jl_repl_entrypoint at 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/jlapi.c:720
> main at /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/cli/loader_exe.c:59
> __libc_start_call_main at 
> /gnu/store/a19xbynxc3sg25xpkwmx7g0mdl7g31hx-glibc-2.35/lib/libc.so.6 (unknown 
> line)
> __libc_start_main at 
> /gnu/store/a19xbynxc3sg25xpkwmx7g0mdl7g31hx-glibc-2.35/lib/libc.so.6 (unknown 
> line)
> _start at /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/bin/julia 
> (unknown line)
> unknown function (ip: (nil))
> Allocations: 145655328 (Pool: 145582643; Big: 72685); GC: 120
> *** This error is usually fixed by running `make clean`. If the error 
> persists, try `make cleanall`. ***
> make[1]: *** [sysimage.mk:89: 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/lib/julia/sys-o.a] Error 1
> make[1]: Leaving directory '/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3'
> make: *** [Makefile:88: julia-sysimg-release] Error 2

Using my patch, it fails with:

--8<---cut here---start->8---
Error in testset OpenBLAS_jll:
Test Failed at 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/share/julia/stdlib/v1.8/OpenBLAS_jll/test/runtests.jl:16
  Expression: dlsym(OpenBLAS_jll.libopenblas_handle, #= 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/share/julia/stdlib/v1.8/OpenBLAS_jll/test/runtests.jl:16
 =# @blasfunc(openblas_set_num_threads); throw_error = false) != nothing
   Evaluated: nothing != nothing
ERROR: LoadError: Test run finished with errors
in expression starting at 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/test/runtests.jl:93
--8<---cut here---end--->8---

Well, I am still missing why the expression

  dlsym(OpenBLAS_jll.libopenblas_handle,
  #= 
/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/share/julia/stdlib/v1.8/OpenBLAS_jll/test/runtests.jl:16
 =#
  @blasfunc(openblas_set_num_threads); throw_error = false)

is evaluated to nothing.  Any idea?

Cheers,
simon






bug#63986: Julia is very slow

2023-06-23 Thread Efraim Flashner
On Fri, Jun 23, 2023 at 03:23:17PM +0200, Simon Tournier wrote:
> Hi Efraim,
> 
> On Fri, 23 Jun 2023 at 12:16, Efraim Flashner  wrote:
> 
> > It should be, but julia fails the precompile stage with openblas-ilp64
> >
> > Precompilation complete. Summary:
> > Total ─── 1006.632176 seconds
> > Generation ── 690.274180 seconds 68.5726%
> > Execution ─── 316.357997 seconds 31.4274%
> >
> > signal (15): Terminated
> > in expression starting at none:0
> > unknown function (ip: 0xf4d81b24)
> > unknown function (ip: 0xf4ed10bb)
> > unknown function (ip: 0xf4eda16f)
> > _ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE at 
> > /gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
> > (unknown line)
> > _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at 
> > /gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
> > (unknown line)
> > _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at 
> > /gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
> > (unknown line)
> > _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at 
> > /gnu/store/wa28l476c1bfshfiqcqbmk75zr8ml152-llvm-13.0.1/lib/libLLVM-13jl.so 
> > (unknown line)
> > operator() at 
> > /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/aotcompile.cpp:580 
> > [inlined]
> > jl_dump_native_impl at 
> > /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/aotcompile.cpp:592
> > jl_write_compiler_output at 
> > /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/precompile.c:94
> > ijl_atexit_hook at 
> > /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/init.c:207
> > jl_repl_entrypoint at 
> > /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/src/jlapi.c:720
> > main at /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/cli/loader_exe.c:59
> > __libc_start_call_main at 
> > /gnu/store/a19xbynxc3sg25xpkwmx7g0mdl7g31hx-glibc-2.35/lib/libc.so.6 
> > (unknown line)
> > __libc_start_main at 
> > /gnu/store/a19xbynxc3sg25xpkwmx7g0mdl7g31hx-glibc-2.35/lib/libc.so.6 
> > (unknown line)
> > _start at /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/bin/julia 
> > (unknown line)
> > unknown function (ip: (nil))
> > Allocations: 145655328 (Pool: 145582643; Big: 72685); GC: 120
> > *** This error is usually fixed by running `make clean`. If the error 
> > persists, try `make cleanall`. ***
> > make[1]: *** [sysimage.mk:89: 
> > /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/lib/julia/sys-o.a] Error 1
> > make[1]: Leaving directory '/tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3'
> > make: *** [Makefile:88: julia-sysimg-release] Error 2
> 
> Using my patch, it fails with:
> 
> --8<---cut here---start->8---
> Error in testset OpenBLAS_jll:
> Test Failed at 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/share/julia/stdlib/v1.8/OpenBLAS_jll/test/runtests.jl:16
>   Expression: dlsym(OpenBLAS_jll.libopenblas_handle, #= 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/share/julia/stdlib/v1.8/OpenBLAS_jll/test/runtests.jl:16
>  =# @blasfunc(openblas_set_num_threads); throw_error = false) != nothing
>Evaluated: nothing != nothing
> ERROR: LoadError: Test run finished with errors
> in expression starting at 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/test/runtests.jl:93
> --8<---cut here---end--->8---

Mine was on aarch64

> Well, I am still missing why the expression
> 
>   dlsym(OpenBLAS_jll.libopenblas_handle,
>   #= 
> /tmp/guix-build-julia-1.8.3.drv-0/julia-1.8.3/usr/share/julia/stdlib/v1.8/OpenBLAS_jll/test/runtests.jl:16
>  =#
>   @blasfunc(openblas_set_num_threads); throw_error = false)
> 
> is evaluated to nothing.  Any idea?

It is something about the wrong internal interface in openblas, I don't
remember exactly what that error came from.

Try with the attached diff.


-- 
Efraim Flashner  רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
diff --git a/gnu/packages/julia.scm b/gnu/packages/julia.scm
index ba54175822..8ba2b480ce 100644
--- a/gnu/packages/julia.scm
+++ b/gnu/packages/julia.scm
@@ -269,7 +269,10 @@ (define-public julia
(substitute* (jlpath "nghttp2")
  (((from "libnghttp2")) (to "libnghttp2" "libnghttp2")))
(substitute* (jlpath "OpenBLAS")
- (((from "libopenblas")) (to "openblas" "libopenblas")))
+ (((from "libopenblas"))
+  ,@(if (target-x86-64?)
+  `((to "openblas" "libopenblas64_" "libopenblas"))
+  `((to "openblas" "libopenblas")
(substitute* (jlpath "OpenLibm")
  (((from "libopenlibm")) (to "openlibm" "libopenlibm")))
(substitute* (jlpath "PCRE2")
@@ -479,12 +482,13 @@ (define-public julia
  "NO_GIT=1" ; build from release tarball.
  "USE_GPL_LIBS=1"   ; proudly