如何创建执行线程? [英] how to create execution threads??

查看:83
本文介绍了如何创建执行线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是Phoenix的新手,我正在创建一个插件,它将进行依赖性分析,然后将IR分区以在多核系统上运行。我无法弄清楚如何创建执行线程。我发现我可以使用Phx :: Threading :: Thread,但由于缺少示例或示例代码,我无法使用它。有人可以给我提供一些小例子,它将IR分成线程或指导我从一些教程,我可以从中获取更多信息abt Thread类。我已经检查了Phoenix文档。

谢谢,
Akshey

Hi ,

I am new to Phoenix and I am working to create a plugin which will do a dependence analysis and then partitions the IR to run on multicore system. I am not able to make out how to create execution threads. I have found that I can use Phx::Threading::Thread but due to lack of examples or sample code I am not able to use it. Can somebody plz provide me with some small example which partitions the IR into threads or direct me to some tutorial from where I can get some more information abt Thread class. I have already checked the Phoenix documentation.

Thanks,
Akshey

推荐答案

你是对的,我们没有关于如何使用多线程的任何好例子。 c2客户端具有多线程功能,但没有其他样本或客户端二进制文件以这种方式设置。

You're right, we don't have any good examples on how to use multithreading. The c2 client is multithread-capable, but no other sample or client binary is set up this way.

A关于我们的并行模型的话。在凤凰城,我们设计了一些东西,以便可以同时处理FunctionUnits。但是,在FunctionUnit中,执行期望是单线程的。我们不希望插件启动自己的线程或(通常)创建可能在多个线程上执行的工作。我无法从你的帖子中看出我们的模型是否符合你的想法,但听起来你想在FunctionUnit中并行,我们不支持。

A word on our parallel model. In Phoenix we've designed things so that FunctionUnits can be processed concurrently. However, within a FunctionUnit execution is expected to be single threaded. We don't expect plugins to initiate their own threads or (generally) to create work that might execute on multiple threads. I can't tell from your post whether our model fits with what you are thinking of doing, but it sounds like you want to go parallel within a FunctionUnit and we don't support that.

(如果你很好奇为什么:通常会有很多函数要编译,并且在函数之间并行我们需要做大量的工作 - 很少会出现并行性受到大函数的限制。而且函数之间的共享状态要少于函数内的共享状态,因此并行模型更直接。)

(If you're curious why: usually there are so many functions to compile that going parallel across functions gives us ample work to do -- only rarely will parallelism be limited by large functions. Also there's much less shared state across functions than within functions, so the parallel model is more straightforward).

如果您正在构建插件并希望在FunctionUnit并行的情况下看到它工作,那么实现并覆盖插件上的IsThreadSafe属性(当然要小心) ,以确保您的插件的阶段或处理程序真的是线程安全的)。然后将-thread控制值设置为c2应运行的线程数,并在多个线程上同时调用插件阶段/处理程序。

If you are building a plugin and want to see it work in the FunctionUnit parallel case, then implement and override the IsThreadSafe property on your plugin (taking care, of course, to make sure that your plugin's phases or handlers are really thread safe). Then set the -thread control value to the number of threads that c2 should run and your plugin phases/handlers will be invoked concurrently on multiple threads.


这篇关于如何创建执行线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆