标签: parallel-processing

英特尔TBB并行化开销

为什么英特尔线程构建模块(TBB)parallel_for有如此大的开销?根据第3.2.2 自动分块Tutorial.pdf其周围半毫秒.这是教程中的一个重点:

注意:对于parallel_for,循环通常需要至少一百万个时钟周期才能提高其性能.例如,在2 GHz处理器上占用至少500微秒的环路可能会受益于parallel_for.

从我到目前为止所读到的内容,TBB在内部使用了线程池(工作线程池)模式,它通过最初只生成工作线程(这需要数百微秒)来防止这种不良开销.

那么花时间呢?使用互斥锁进行数据同步并不是那么慢吗?此外,TBB不使用无数据结构进行同步吗?

c++ parallel-processing tbb overhead lock-free

4
推荐指数
1
解决办法
3295
查看次数

C#中的并行处理/并行编程

我需要处理多个函数,并执行返回相同类型记录的结果.考虑到我的功能,我在visual studio 2010下使用c#:

class Search{
public list<wrecords> GetrecordsofAAA(string term);
public list<wrecords> GetrecordsofBBB(string term);
public list<wrecords> GetrecordsofCCC(string term);
}
Run Code Online (Sandbox Code Playgroud)

我用这种方式调用函数

list<wrecords> records1 = Search.GetrecordsofAAA(heart);
list<wrecords> records2 = Search.GetrecordsofBBB(heart);
list<wrecords> records3 = Search.GetrecordsofCCC(heart);
Run Code Online (Sandbox Code Playgroud)

这是系列处理.

如果可能的话,我需要同时填写记录1,记录2和记录3.

c# parallel-processing visual-studio-2010

4
推荐指数
1
解决办法
1336
查看次数

Visual Studio 2010无法使用System.Threading.Tasks;

我试图并行执行一些进程.这是我第一次这样做,尝试:使用System.Threading.Tasks; 任务将以红色标出:

The Type or namespace name "Tasks" does not exist in the namespace System.Threading(are you missing an assembly reference?)
Run Code Online (Sandbox Code Playgroud)

我该如何解决!?

c# parallel-processing visual-studio-2010 task-parallel-library

4
推荐指数
1
解决办法
1万
查看次数

何时不使用MPI

这不是关于MPI的特定技术编码方面的问题.我是MPI的新手,并不想让我自己以错误的方式使用库,因此在这里发布问题.

据我所知,MPI是一个在分布式内存模型上构建并行应用程序的环境.

我有一个与Infiniband互连的系统,其唯一目的是进行一些非常耗时的操作.我已经打破了算法并行执行,所以我真的只使用MPI通过Infiniband在多个节点之间传输数据(中间步骤的结果),我相信可以简单地使用OpenIB来做.

我是以正确的方式使用MPI吗?还是我弯曲了系统的初衷?

parallel-processing hpc mpi

4
推荐指数
1
解决办法
1077
查看次数

并行文件匹配,Python

我正在尝试改进扫描文件中的恶意代码的脚本.我们在文件中有一个正则表达式模式列表,每行一个模式.这些正则表达式适用于grep,因为我们当前的实现基本上是一个bash脚本find\grep combo.bash脚本在我的基准测试目录上需要358秒.我能够编写一个在72秒内执行此操作的python脚本,但希望进一步提高.首先,我将发布基本代码然后调试我尝试过:

import os, sys, Queue, threading, re

fileList = []
rootDir = sys.argv[1]

class Recurser(threading.Thread):

    def __init__(self, queue, dir):
    self.queue = queue
    self.dir = dir
    threading.Thread.__init__(self)

    def run(self):
    self.addToQueue(self.dir)

    ## HELPER FUNCTION FOR INTERNAL USE ONLY
    def addToQueue(self,  rootDir):
      for root, subFolders, files in os.walk(rootDir):
    for file in files:
       self.queue.put(os.path.join(root,file))
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)
      self.queue.put(-1)

class Scanner(threading.Thread):

    def __init__(self, queue, patterns):
    self.queue = queue …
Run Code Online (Sandbox Code Playgroud)

python string parallel-processing multithreading gil

4
推荐指数
2
解决办法
4229
查看次数

如何等待后台工作者完成处理?

我有3个后台工作人员,每个工作人员处理一个24位位图图像(Y,Cb,Cr)的通道.每个8位图像的处理需要几秒钟,并且它们可能无法同时完成.

我想在完成后将频道合并为一个图像.单击一个按钮时,每个按钮都会backgroundWorkerN.RunWorkerAsync()启动,当它们完成时,我会设置一个标志为true.我尝试使用while循环while (!y && !cb && !cr) { }来连续检查标志,直到它们为真,然后退出循环并继续处理下面的代码,这是将通道合并回来的代码.但是当我运行它时,过程永远不会结束.

   private void button1_Click(object sender, EventArgs e)
   {
        backgroundWorker1.RunWorkerAsync();
        backgroundWorker2.RunWorkerAsync();
        backgroundWorker3.RunWorkerAsync();

        while (!y && !cb && !cr) { }

        //Merge Code
   }
Run Code Online (Sandbox Code Playgroud)

c# parallel-processing backgroundworker winforms

4
推荐指数
1
解决办法
8742
查看次数

跨多个核心在bash中运行循环过程

我有一个包含以下循环的shell脚本.

i=0  
upperlimit=$verylargevariable  
do  
   complexstuff RunManager file $i  
   i= 'expr $i +1'  
done
Run Code Online (Sandbox Code Playgroud)

这个脚本在四核机器上运行,据此top,在执行循环的一次迭代时,使用每个核心的大约15%.我想将它分布在四个核心上,以便循环的每次迭代执行complexstuff四次,每个核心一次,这样可以更有效地使用资源.我们谈论的是目前需要几个小时的计算,因此这里的效率不仅仅是良好的实践.(每次迭代的输出显然与前一次迭代无关.)

PS:主机是运行Cent-OS的服务器,如果有帮助的话.

parallel-processing bash centos

4
推荐指数
2
解决办法
3749
查看次数

Perl和流程管理

我正在使用Perl开发一个非常大的企业应用程序,有几十个模块等,主要用于通过Web抓取一些东西.

我写的一个子程序是进行图像检索和分析.对于我发送给它的每个参数,通常需要几秒钟才能完成.所以我将它发送到另一个进程(分叉...).问题是,经过一段时间后系统变得非常不稳定,内存已经填满.

问题:

  1. 是因为创建了每个进程,在单独的内存位置创建父数据的副本?如果是这样,是否意味着每个孩子都拥有所有模块的副本?(还有几十......)
  2. 释放这些内存/管理这些过程的最佳方法是什么?

memory parallel-processing perl ipc process

4
推荐指数
1
解决办法
218
查看次数

D任务池等待直到完成所有任务

这与我之前的问题有关:D并发写入缓冲区

假设您有一段由2个连续代码块A和B组成的代码,其中B依赖于A.这在编程中非常常见.A和B都包含一个循环,每个迭代可以并行运行:

double[] array = [ ... ]; // has N elements

// A
for (int i = 0; i < N; i++)
{
    job1(array[i]); // new task
}

// wait for all job1's to be done

// B
for (int i = 0; i < N; i++)
{
    job2(array[i]); // new task
}
Run Code Online (Sandbox Code Playgroud)

B只能在A完成时执行.在执行B之前,如何等待A的所有任务完成?

parallel-processing concurrency d task wait

4
推荐指数
1
解决办法
250
查看次数

如何在Perl中生成并行HTTP请求,并按顺序接收它们?

使用Perl,我正在寻找一种简单的方法来并行执行少量HTTP请求,在这里我得到的响应与我们在完成后发送的顺序相同,例如:

my ($google, $perl) = foobar(GET => 'http://www.google.com/',
                             GET => 'http://www.perl.org/');
Run Code Online (Sandbox Code Playgroud)

我应该看一个模块吗?

我知道我可以手工完成簿记,但是在使用jQuery的when方法能够做到这一点之后我感到被宠坏了,我很想用Perl做一个简单的解决方案.

谢谢你的帮助.

parallel-processing perl http

4
推荐指数
2
解决办法
3778
查看次数