简体   繁体   English

将数据从一个.exe传递到另一个

[英]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. 我对C ++相对缺乏经验,但是我需要构建一个框架以重新整理一些数据。 Not necessarily relevant, but the general flow path of my data needs to go like this: 不一定相关,但是我的数据的一般流动路径需要像这样:

  1. Data is generated in a python script 数据在python脚本中生成
  2. The python object is passed to a compiled C++ extension python对象传递给已编译的C ++扩展
  3. The C++ extension makes some changes and passes the data (presumably a pointer?) to compiled C++/CUDA code (.exe) C ++扩展进行了一些更改,并将数据(可能是指针?)传递给已编译的C ++ / CUDA代码(.exe)
  4. C++/CUDA .exe does stuff C ++ / CUDA .exe做的东西
  5. Data is handled back in the python script and sent to more python functions 数据将在python脚本中处理并发送给更多python函数

Step 3. is where I'm having trouble. 步骤3是我遇到麻烦的地方。 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? 我将如何调用包含CUDA代码的.exe,使其可以访问C ++ python扩展中看到的数据? 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. 我已经看到了有关创建共享内存的参考,但是我也不清楚那里的详细信息。

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. 在进程之间使用TCP或UDP套接字交换数据。

  • 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. 在进程之间使用Unix域套接字。

And there are more options but the above are probably the most common ones. 并且还有更多选择,但是以上可能是最常见的选择。

What you need to research is IPC (Inter-Process Communication). 您需要研究的是IPC(进程间通信)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM