[go: nahoru, domu]

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

shmmap and shmvar does not exist in GDL #860

Open
brandy125 opened this issue Dec 16, 2020 · 17 comments
Open

shmmap and shmvar does not exist in GDL #860

brandy125 opened this issue Dec 16, 2020 · 17 comments
Labels
c++-only enhancement New feature or request

Comments

@brandy125
Copy link

Are there any plans to implement shmmap and shmvar in GDL?

@GillesDuvert
Copy link
Contributor

should be, er, straightforward for somebody with a modicum of ease in C...

@GillesDuvert GillesDuvert added enhancement New feature or request c++-only labels Apr 21, 2021
@brandy125
Copy link
Author

I am coming back to this old issue because I would need it a lot. I am writing programs for multi CPU machines and do not know how I can share the data between the processes without using shmmap and shmvar.

Can anybody work on that or is there any workaround?

@alaingdl
Copy link
Contributor
alaingdl commented May 7, 2023

Could you please provide an example of usage ?

It is not clear for me, I never had to use that. I also suppose it is totally different from what we do on multi-cores machines ? When I use Slurm or PBS I reserve before the rum some resources, including both CPUs (cores) & RAM ... on a node ..

Are such functions useful nowadays ? (it is a naive question)

@brandy125
Copy link
Author

Let me show you an easy example. Open two terminals with two IDL sessions.

Session 1:

IDL> shmmap,'anynamehere',/long,5
IDL> tmp=shmvar('anynamehere')   
IDL> print,tmp                   
           0           0           0           0           0

Now you open a second session and type the same:

Session 2:

IDL> shmmap,'anynamehere',/long,5
IDL> tmp=shmvar('anynamehere')   
IDL> print,tmp                   
           0           0           0           0           0

back to session 1 you fill up the variable:

Session 1:

IDL> tmp(0)=findgen(5)           
IDL> print,tmp        
           0           1           2           3           4

Now on session 2 magically the contents of the variable has changed as well:
Session 2:

IDL> print,tmp        
           0           1           2           3           4

And that is what I need. I want to have access on 80 parallel sessions to the same big array so that all the sessions can work on the same data.
Do you have any idea if this can be implemented easily or do you know anything else I can do to share the same array to multiple CPUs?

@alaingdl
Copy link
Contributor
alaingdl commented May 7, 2023
  • thanks for the example, very convenient
  • does it have any 'vague) relationship with the "sem" functionalities ? (example in testsuite/wrong/test_sem.pro)

@alaingdl
Copy link
Contributor
alaingdl commented May 7, 2023

in fact man shm_open provides examples on my Linux ... And man shmget too ... Which one should we consider ?!

@brandy125
Copy link
Author

Ahh, nice, I think we need both.

@brandy125
Copy link
Author

Hi @alaingdl just wanted to know if there is any progress in this issue or any workaround?

@alaingdl
Copy link
Contributor

FYI, my student @BoudjemaaS just started to have a look on that. Not obvious for us if we are able to do it, but we will try hard, and @Saynkas will help when he will have clarify #1311 😄

@brandy125
Copy link
Author
brandy125 commented May 31, 2023 via email

@brandy125
Copy link
Author

Hi @alaingdl did you have any progress on this issue?
It would be very handy.

@alaingdl
Copy link
Contributor

Unfortunately no progress. With my student, we did succeed to play with the pure C side of the code without too much problem, but we failed to incorporate it into GDL. It would be great that some experts in C/c++ like @GillesDuvert @slayoo and other give few times on this topic.

Not sure CALL_EXTERNAL could be useful on such topic. Any input welcome.

@GillesDuvert
Copy link
Contributor

At first glance this is 'just' having the variable pointer (every GDL variable have such pointer) point to a shared memory region, allocated by mmap() instead of the default allocator.
As it goes deep in GDL, and seen the numerous comments in IDL's help page for shmmap, and the need to support all the related functions, it is not 'just' adding a new allocator for variables. But I'm certain it can be managed.

@brandy125
Copy link
Author
brandy125 commented Nov 23, 2023 via email

@alaingdl
Copy link
Contributor
alaingdl commented Nov 24, 2023

@brandy125 & @GillesDuvert based on https://gist.github.com/drmalex07/5b72ecb243ea1f5b4fec37a6073d9d23
I do have a very preliminary working code in GDL, the 2 sessions do exchange memory and I can change the values ...

For sure I will need help to go further. I can send the few files by email (send one to me) ...

@GillesDuvert
Copy link
Contributor

As I said in #1677 (comment) I'll do that soon. @alaingdl your code changes are welcome.

@brandy125
Copy link
Author
brandy125 commented Dec 8, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++-only enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants