Re: dub ldc2 static linking

2022-10-28 Thread Yura via Digitalmars-d-learn

On Friday, 28 October 2022 at 09:02:22 UTC, Kagamin wrote:

On Friday, 28 October 2022 at 02:46:42 UTC, ryuukk_ wrote:
I'm just right now having an issue with glibc version mismatch 
for my server


Just compile with an old enough glibc, 2.14 works for me.


Indeed, if I got it right it seems to be much easier and 
straightforward than recompiling virtually everything you touch 
against musle, starting from Blas, druntime library, etc.


Re: dub ldc2 static linking

2022-10-27 Thread Yura via Digitalmars-d-learn
Thank you! I tried this one, but it did not help. All these 
warnings survived :
"... Using 'getservbyport' in statically linked applications 
requires at runtime the shared libraries from the glibc version 
used for linking"


On Thursday, 27 October 2022 at 14:18:01 UTC, Anonymouse wrote:

On Thursday, 27 October 2022 at 08:08:38 UTC, Yura wrote:

What am I doing wrong? Any way to fix it?


https://forum.dlang.org/thread/gghcyaapjwfcpnvks...@forum.dlang.org worked for 
me.





dub ldc2 static linking

2022-10-27 Thread Yura via Digitalmars-d-learn

Dear All,
I am trying to create a static executable to be able to run it on 
virtually any linux x86_64 OS. At the end I get a binary, 
however, multiple warnings are printed after compilation.


My dub.sdl:

dependency "mir" version="~>3.2.3"
dependency "lubeck" version="~>1.5.1"
lflags "-lopenblas" "-lgfortran"
dflags "--static" "-O3"

dub build --force --compiler=path_to_ldc/ldc2

curl.d:(.text._D3std3net4curl7CurlAPI7loadAPIFZPv+0xd): warning: 
Using 'dlopen' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for 
linking


and many other warnings like this.

What am I doing wrong? Any way to fix it?


Re: library to solve the system of linear equations

2022-10-26 Thread Yura via Digitalmars-d-learn
The workaround is to compile without --release mode, but using 
the "O3" ldc flag instead does the job - the binary is fast, yet 
the try - catch block executes properly.


On Wednesday, 26 October 2022 at 20:13:37 UTC, Yura wrote:
OK, got the problem solved by adding the following lines in my 
dub.sdl file:


lflags "-lopenblas" "-lgfortran"
dflags "--static"

However, one problem still remains. Apparently, when compiled 
with dub --release mode I got segfault in my try - catch block. 
Any solution to this?



On Wednesday, 26 October 2022 at 12:24:47 UTC, Yura wrote:
I am now trying to compile the code statically using the dub 
manager via the following command line:


dub build --force --build=release --compiler=path_to_ldc2/ldc2

and having these lines in my dub.sdl file:

dependency "mir" version="~>3.2.3"
dependency "lubeck" version="~>1.5.1"
dflags "-static"

For some reasons it does not work:

(.text+0x2f2): undefined reference to `_gfortran_concat_string'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libopenblas.a(dormlq.o):(.text+0x784):
 more undefined references to `_gfortran_concat_string' follow
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1

Any idea of what I am doing wrong? Should I also specify 
something in my dub.sdl via lflags?


Thank you in advance!

On Tuesday, 18 October 2022 at 17:01:53 UTC, Yura wrote:
Yes, did the same and it worked. The amazing thing is that 
the system solver turned out to be natively parallel and runs 
smoothly!


On Tuesday, 18 October 2022 at 15:22:02 UTC, mw wrote:
On Tuesday, 18 October 2022 at 09:56:09 UTC, Siarhei 
Siamashka wrote:

On Monday, 17 October 2022 at 20:05:24 UTC, mw wrote:

On Monday, 17 October 2022 at 19:54:12 UTC, Yura wrote:

it is possible to install the most recent ldc and gdc 
compilers on Ubuntu 18.04?


Yes, I used LDC on the same system.


What's the recommended way to have up to date D compilers 
in Ubuntu?


I just download the official prebuilt binary from the ldc 
github repo.





Re: library to solve the system of linear equations

2022-10-26 Thread Yura via Digitalmars-d-learn
OK, got the problem solved by adding the following lines in my 
dub.sdl file:


lflags "-lopenblas" "-lgfortran"
dflags "--static"

However, one problem still remains. Apparently, when compiled 
with dub --release mode I got segfault in my try - catch block. 
Any solution to this?



On Wednesday, 26 October 2022 at 12:24:47 UTC, Yura wrote:
I am now trying to compile the code statically using the dub 
manager via the following command line:


dub build --force --build=release --compiler=path_to_ldc2/ldc2

and having these lines in my dub.sdl file:

dependency "mir" version="~>3.2.3"
dependency "lubeck" version="~>1.5.1"
dflags "-static"

For some reasons it does not work:

(.text+0x2f2): undefined reference to `_gfortran_concat_string'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libopenblas.a(dormlq.o):(.text+0x784):
 more undefined references to `_gfortran_concat_string' follow
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1

Any idea of what I am doing wrong? Should I also specify 
something in my dub.sdl via lflags?


Thank you in advance!

On Tuesday, 18 October 2022 at 17:01:53 UTC, Yura wrote:
Yes, did the same and it worked. The amazing thing is that the 
system solver turned out to be natively parallel and runs 
smoothly!


On Tuesday, 18 October 2022 at 15:22:02 UTC, mw wrote:
On Tuesday, 18 October 2022 at 09:56:09 UTC, Siarhei 
Siamashka wrote:

On Monday, 17 October 2022 at 20:05:24 UTC, mw wrote:

On Monday, 17 October 2022 at 19:54:12 UTC, Yura wrote:

it is possible to install the most recent ldc and gdc 
compilers on Ubuntu 18.04?


Yes, I used LDC on the same system.


What's the recommended way to have up to date D compilers in 
Ubuntu?


I just download the official prebuilt binary from the ldc 
github repo.





Re: library to solve the system of linear equations

2022-10-26 Thread Yura via Digitalmars-d-learn
I am now trying to compile the code statically using the dub 
manager via the following command line:


dub build --force --build=release --compiler=path_to_ldc2/ldc2

and having these lines in my dub.sdl file:

dependency "mir" version="~>3.2.3"
dependency "lubeck" version="~>1.5.1"
dflags "-static"

For some reasons it does not work:

(.text+0x2f2): undefined reference to `_gfortran_concat_string'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libopenblas.a(dormlq.o):(.text+0x784):
 more undefined references to `_gfortran_concat_string' follow
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1

Any idea of what I am doing wrong? Should I also specify 
something in my dub.sdl via lflags?


Thank you in advance!

On Tuesday, 18 October 2022 at 17:01:53 UTC, Yura wrote:
Yes, did the same and it worked. The amazing thing is that the 
system solver turned out to be natively parallel and runs 
smoothly!


On Tuesday, 18 October 2022 at 15:22:02 UTC, mw wrote:
On Tuesday, 18 October 2022 at 09:56:09 UTC, Siarhei Siamashka 
wrote:

On Monday, 17 October 2022 at 20:05:24 UTC, mw wrote:

On Monday, 17 October 2022 at 19:54:12 UTC, Yura wrote:

it is possible to install the most recent ldc and gdc 
compilers on Ubuntu 18.04?


Yes, I used LDC on the same system.


What's the recommended way to have up to date D compilers in 
Ubuntu?


I just download the official prebuilt binary from the ldc 
github repo.





Re: library to solve the system of linear equations

2022-10-18 Thread Yura via Digitalmars-d-learn
Yes, did the same and it worked. The amazing thing is that the 
system solver turned out to be natively parallel and runs 
smoothly!


On Tuesday, 18 October 2022 at 15:22:02 UTC, mw wrote:
On Tuesday, 18 October 2022 at 09:56:09 UTC, Siarhei Siamashka 
wrote:

On Monday, 17 October 2022 at 20:05:24 UTC, mw wrote:

On Monday, 17 October 2022 at 19:54:12 UTC, Yura wrote:

it is possible to install the most recent ldc and gdc 
compilers on Ubuntu 18.04?


Yes, I used LDC on the same system.


What's the recommended way to have up to date D compilers in 
Ubuntu?


I just download the official prebuilt binary from the ldc 
github repo.





Re: parallel is slower than serial

2022-10-18 Thread Yura via Digitalmars-d-learn

Thank you, folks, for your hints and suggestions!

Indeed, I re-wrote the code and got it substantially faster and 
well paralleled.


Insted of making inner loop parallel, I made parallel both of 
them. For that I had to convert 2d index into 1d, and then back 
to 2d. Essentially I had to calculate each element Aij of the 
matrix, and then I put everything to 1d array.


And yes, A = A ~ Aij was very slow, to avoid it I had to use 2d 
-> 1d mapping. I will check your solution as well as I like it 
too.


The more I use the D Language, the more I like it.

On Tuesday, 18 October 2022 at 16:07:22 UTC, Siarhei Siamashka 
wrote:

On Tuesday, 18 October 2022 at 11:56:30 UTC, Yura wrote:

```D
// Then for each Sphere, i.e. dot[i]
// I need to do some arithmetics with itself and other dots
// I have only parallelized the inner loop, i is fixed.


It's usually a much better idea to parallelize the outer loop. 
Even OpenMP tutorials explain this: 
https://ppc.cs.aalto.fi/ch3/nested/ (check the "collapse it 
into one loop" suggestion from it).



```D
for (auto j=0;j

This way of appending to an array is very slow and `A ~= 
Ai[j];` is much faster. And even better would be `A ~= Ai;` 
instead of the whole loop.





parallel is slower than serial

2022-10-18 Thread Yura via Digitalmars-d-learn

Dear All,

I am trying to make a simple code run in parallel. The parallel 
version works, and gives the same number as serial albeit slower.


First, the parallel features I am using:

import core.thread: Thread;
import std.range;
import std.parallelism:parallel;
import std.parallelism:taskPool;
import std.parallelism:totalCPUs;

// Then, I have an array of structures

shared Sphere [] dot;

// Each Sphere is

struct Sphere {
  string El;
  double x;
  double y;
  double z;
  double S;
  double Z;
  double V;
}

// Then for each Sphere, i.e. dot[i]
// I need to do some arithmetics with itself and other dots
// I have only parallelized the inner loop, i is fixed.

// parallel loop
auto I = std.range.iota(0,dot.length);
shared double [] Ai;
Ai.length = dot.length;
foreach (j;parallel(I)) {
  Ai[j] = GETAij (i, j, dot[i], dot[j]);
}

for (auto j=0;jWhat I am doing wrong? Any advanced options for the ldc2 
compiler? Many thanks in advance!




Re: library to solve the system of linear equations

2022-10-17 Thread Yura via Digitalmars-d-learn
Dear All, Thank you so much for your replies and hints! I got it 
working today. All the libraries are properly linked and the 
Equation solver runs smoothly.


The compilers turned out to be problematic though. The "Mir" 
library does not work with the Ubuntu 18.04 gdc and ldc 
compilers. I have managed to install the latest version dmd, and 
it works. But I suspect that the dmd compiler is not optimal in 
terms of performance. The question becomes whether it is possible 
to install the most recent ldc and gdc compilers on Ubuntu 18.04?


The good thing is that I have also managed to get this code 
working in parallel.


Thank you again!

On Saturday, 15 October 2022 at 13:11:04 UTC, Siarhei Siamashka 
wrote:

On Friday, 14 October 2022 at 21:38:45 UTC, Yura wrote:

in the top of my el.d file I have:
```D
/+dub.sdl:
dependency "mir-algorithm" version="~>3.16.12"
+/
import std.stdio;
import std.string;
import std.conv;
import std.exception : assertThrown;
import std.math;
import mir.ndslice;
```

however, when I try to compile it (gdc el.d) it gives me the 
following error message:


el.d:11:8: error: module ndslice is in file 'mir/ndslice.d' 
which cannot be read

 import mir.ndslice;


This all looks good, except for the `"gdc el.d"` part. A small 
application contained in a single .d file can be run like a 
script via `"dub el.d"`. This is explained at 
https://dub.pm/advanced_usage.html


For compiling highly optimized final binaries you can run `"dub 
build --build=release --single --compiler=ldc2 el.d"` (to use 
LDC) or `"dub build --build=release --single --compiler=gdc 
el.d"` (to use GDC).





Re: library to solve the system of linear equations

2022-10-14 Thread Yura via Digitalmars-d-learn

On Friday, 14 October 2022 at 18:37:00 UTC, Sergey wrote:

On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote:

Dear All,

I am very new to D, and it has been a while since I coded in 
anything than Python. I am using just notepad along with the 
gdc compiler.


At the moment I need to solve the system of liner equations:

A00*q0 + A01*q1 + A02*q2 ... = -V0
A10*q0 + A11*q1 + A12*q2 ... = -V1
...

Could someone please provide a quick d solution for this, 
including details on how to install the library & link it to 
the code? I do not need anything advanced, just the easiest 
option.


I am sorry for too basic question, just want to check my idea 
quickly. Thank you!


Firstly I will suggest to install dub - the D package manager. 
It will be easier to isntall other libraries using it.


Install openblas in your Ubuntu system. After that you can 
create a new folder and type in terminal

```
dub init
```

The main part will be about "dependencies". Type "lubeck".
After that you could check the example of the simple program 
here:

https://github.com/kaleidicassociates/lubeck/blob/master/example/source/app.d

It is exactly solving simple system of linear equations.
Link to the package where you can find additional details and 
documentation: https://code.dlang.org/packages/lubeck


Thank you!

First, I installed dub on Linux. Then I installed both 
libopenblas-dev and libopenblas-base.
After that I tried to initiate a new project via dub init. I 
tried to use the following dependency:
"mir-algorithm". After I got dub.sdl file that contains at the 
end line:


dependency "mir-algorithm" version="~>3.16.12"

in the top of my el.d file I have:
/+dub.sdl:
dependency "mir-algorithm" version="~>3.16.12"
+/
import std.stdio;
import std.string;
import std.conv;
import std.exception : assertThrown;
import std.math;
import mir.ndslice;

however, when I try to compile it (gdc el.d) it gives me the 
following error message:


el.d:11:8: error: module ndslice is in file 'mir/ndslice.d' which 
cannot be read

 import mir.ndslice;
^
import path[0] = /usr/lib/gcc/x86_64-linux-gnu/8/include/d

What am I doing wrong? Should I specify the library upon 
compilation?


I am sorry, I am feeling I am asking too basic question.

Thank you!


library to solve the system of linear equations

2022-10-14 Thread Yura via Digitalmars-d-learn

Dear All,

I am very new to D, and it has been a while since I coded in 
anything than Python. I am using just notepad along with the gdc 
compiler.


At the moment I need to solve the system of liner equations:

A00*q0 + A01*q1 + A02*q2 ... = -V0
A10*q0 + A11*q1 + A12*q2 ... = -V1
...

I have all my Aij coefficients in the double [][] A array, and V 
numbers in the array double [] b.


Is there any quick D solution for it? Something like in python 
one can do:


numpy.linalg.solve(a,b) ?

Quick web search revealed a few scientific libraries for D like 
Mir or lubek.


I am working under Ubuntu 18.04 and compiling my code like " gdc 
solv.d"


Could someone please provide a quick d solution for this, 
including details on how to install the library & link it to the 
code? I do not need anything advanced, just the easiest option.


I am sorry for too basic question, just want to check my idea 
quickly. Thank you!