unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Damien Mattei <damien.mattei@gmail.com>
Cc: guile-user <guile-user@gnu.org>, guile-devel <guile-devel@gnu.org>
Subject: Re: fibers,questions about thread id and mutation of vectors
Date: Fri, 13 Jan 2023 13:23:32 +0100	[thread overview]
Message-ID: <bb0e77e3-8da3-32fb-6726-f7cabba699ea@telenet.be> (raw)
In-Reply-To: <CADEOadfrNgjKixyEtsreQT0=HkNUPhcVvgLi+PhwwwFtTDPLAQ@mail.gmail.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 1578 bytes --]

>   for (i=start; i<=stop; i++)  { /* i is private by default */
> 
>     scm_init_guile();
>     scm_call_1( func , scm_from_int(i) );

IIUC, you are calling scm_init_guile once per index, whereas calling it 
once per thread would suffice.  For better performance, I propose doing 
it once per thread.

On 13-01-2023 12:10, Damien Mattei wrote:
> there should be difference in implementation of Guile between Mac OS and 
> Linux but i do not know the inner mechanism and algorithm used to run 
> Guile in a C environment,what  scm_init_guile() is doing?

Guile is free software, you can download the source code to read what 
scm_init_guile is doing.

> why must it be placed under the // region on Linux (with slower result)

 From the manual:

6.4  Each thread that wants to use functions from the Guile API needs to 
put itself into guile mode with either ‘scm_with_guile’ or 
‘scm_init_guile’. The global state of Guile is initialized automatically 
when the first thread enters guile mode.

OpenMP does multi-threading, so you need to call scm_init_guile or 
scm_with_guile.

> and anywhere under MacOS ? (speed up code)

You need to do it on non-Linux too -- the extract from the manual does 
not make a 'except on MacOS' exception.  It might work without 
scm_init_guile in some circumstances, but this is not at all guaranteed.

If you want to know the difference between MacOS and Linux in the 
implementation of scm_init_guile, you can read the source code of 
scm_init_guile as mentioned before.

Greetings,
Maxime.

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2023-01-13 12:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 10:20 fibers,questions about thread id and mutation of vectors Damien Mattei
2023-01-06 14:12 ` Maxime Devos
2023-01-06 15:06   ` Damien Mattei
2023-01-06 17:06     ` Damien Mattei
2023-01-06 17:06     ` Maxime Devos
2023-01-13 11:10       ` Damien Mattei
2023-01-13 12:23         ` Maxime Devos [this message]
2023-01-17  9:42           ` Damien Mattei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb0e77e3-8da3-32fb-6726-f7cabba699ea@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=damien.mattei@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).