Kevin
Kevin

Reputation: 41

Pass Data from One .exe to Another

I'm relatively inexperienced with C++, but I need to build a framework to shuffle some data around. Not necessarily relevant, but the general flow path of my data needs to go like this:

  1. Data is generated in a python script
  2. The python object is passed to a compiled C++ extension
  3. The C++ extension makes some changes and passes the data (presumably a pointer?) to compiled C++/CUDA code (.exe)
  4. C++/CUDA .exe does stuff
  5. Data is handled back in the python script and sent to more python functions

Step 3. is where I'm having trouble. How would I go about calling the .exe containing the CUDA code in a way that it can access the data that is seen in the C++ python extension? I assume I should be able to pass a pointer somehow, but I'm having trouble finding resources that explain how. I've seen references to creating shared memory, but I'm unclear on the details there, as well.

Upvotes: 0

Views: 1077

Answers (1)

Jesper Juhl
Jesper Juhl

Reputation: 31465

There are many ways two executables can exchange data.

Some examples:

  • write/read data to/from a shared file (don't forget locking so they don't stumble on eachother).

  • use TCP or UDP sockets between the processes to exchange data.

  • use shared memory.

  • if one application starts the other you can pass data via commandline arguments or in the environment.

  • use pipes between the processes.

  • use Unix domain sockets between the processes.

And there are more options but the above are probably the most common ones.

What you need to research is IPC (Inter-Process Communication).

Upvotes: 3

Related Questions