Loading...
You are not logged-in Login/Register





  • Posts   Search Threads
  • desiramoobranz.co.nzJune 10, 2009 9:48 PM PDT   
    Coupling two programs with shared memory

    Hi,

    This is not really a threading problem but I assume the most appropriate place to ask this question. Can anyone offer advice on how to pass data between two independent programs where one feeds data for the other to use as input. I have seen $shared_common statement in HP which puts the common block in shared memory and wondered this existed within intel.

    For example I need to do the the following

    Program A sets values

    Program B takes values (from A using some form of shared memory between the two programs) performs calculations sets new values for input into program A for x time steps.


    These two programs are independent of each other and run independently. My research requires they pass data to each other by  some linkage.

    Thank you in advance for your help.

    Desi 
     

    jaredkeithwhiteJune 11, 2009 12:41 AM PDT
    Rate
     
    Re: Coupling two programs with shared memory


    You should look at something like MPI.  To my knowledge, modern operating systems are not going to offer you much support in the way of two programs accessing one another's memory.  You can find some good resources about MPI here:

    http://www.mcs.anl.gov/research/projects/mpi/

    Also:

    http://www.open-mpi.org/

    Additionally, the Intel Compiler (for both C++ / Fortran) support OpenMPI.

    Regards,
    -Jared



    Hi,

    This is not really a threading problem but I assume the most appropriate place to ask this question. Can anyone offer advice on how to pass data between two independent programs where one feeds data for the other to use as input. I have seen $shared_common statement in HP which puts the common block in shared memory and wondered this existed within intel.

    For example I need to do the the following

    Program A sets values

    Program B takes values (from A using some form of shared memory between the two programs) performs calculations sets new values for input into program A for x time steps.


    These two programs are independent of each other and run independently. My research requires they pass data to each other by  some linkage.

    Thank you in advance for your help.

    Desi 



    Raf SchietekatJune 11, 2009 2:22 AM PDT
    Rate
     
    Re: Coupling two programs with shared memory

    POSIX support takes the form of shm_open(3) and shm_unlink(3), which build on top of mmap(2).



    pvonkaenelJune 11, 2009 5:33 AM PDT
    Rate
     
    Re: Coupling two programs with shared memory


    Under Windows I 've used a block of named shared memory to pass data between applications.  You use CreateFileMapping() and MapViewOfFile() on one side and OpenFileMapping() and MapViewOfFile() on the other.  However you need to be very careful about unsynchronized access into the memory from multiple applications and must use the heavy weight named synchronization objects which are quite expensive.

    In my case it work very well in a pipelined system where events were triggered in one app when data was available for consumption in other apps.

    Peter


    adunsmoorJune 11, 2009 9:16 AM PDT
    Rate
     
    Re: Coupling two programs with shared memory

    The boost library offers C++ interfaces for both interprocess communication through shared memory and MPI.

    IPC:  http://www.boost.org/doc/libs/1_39_0/doc/html/interprocess.html

    MPI: http://www.boost.org/doc/libs/1_39_0/doc/html/mpi.html

    I haven't used either of these but happened to read the documentation yesterday.   The interprocess library seemed well put together and hid some of the intracacies of using the lower levels interfaces.  Especially if you have to do any cross platform work.


    Raf SchietekatJune 11, 2009 10:08 PM PDT
    Rate
     
    Re: Coupling two programs with shared memory

    "The boost library offers C++ interfaces for both interprocess communication through shared memory and MPI."
    Going with boost is rarely a bad idea, I was thinking of amending my suggestion with a reference myself.

    "Especially if you have to do any cross platform work."
    Without boost or even if I don't really need it (all targets would have to provide it), I would probably try to implement shm_open and shm_unlink as adapters in terms of the native API (which was not specified), instead of inventing yet another layer.

    desiramoobranz.co.nzJune 14, 2009 3:55 PM PDT
    Rate
     
    Re: Coupling two programs with shared memory

    Many thanks for your replies. I have implemented the, CreateShareBuffer(),OpenShareBuffer(),CloseShareBuffer(), DeleteShareBuffer() approach with success. Problem solved now.

    Cheers

    Desi


Forum jump:  

Intel Software Network Forums Statistics

16,376 users have contributed to 46,363 threads and 164,030 posts to date.

In the past 24 hours, we have 11 new thread(s) 28 new posts(s), and 25 new user(s).

In the past 3 days, the most popular thread for everyone has been Program compiles in release but not debug The most posts were made to You need to show us the whole The post with the most views is try_pop in concurrent_queue

Please welcome our newest member fruitbrown


For more complete information about compiler optimizations, see our Optimization Notice.