English 中文(简体)
• 为(a)住宿提供现成的私人预置缓冲?
原标题:Provide thread private preallocated buffer to a parallelized for() loop?

我的方案包括(a)按线处理一些原始图像数据,我想将这种数据与公开图像相平行:

...
#if defined(_OPENMP)
        int const  threads = 8;
        omp_set_num_threads( threads );
        omp_set_dynamic( threads );
#endif
        int line = 0;
#pragma omp parallel private( line )
        {
            // tell the compiler to parallelize the next for() loop using static
            // scheduling (i.e. balance workload evenly among threads),
            // while letting each thread process exactly one line in a single run
#pragma omp for schedule( static, 1 )
            for( line = 0 ; line < max; ++line ) {
                // some processing-heavy code in need of a buffer
            }
        } // end of parallel section
....

www.un.org/Depts/DGACM/index_spanish.htm 问题是:。

可否利用标准的开放式管理计划 pragma/Function向执行我的住所的团队的每一对面提供一个个人(预定地点)缓冲(点)。 (需要消除每座休息室分配新的缓冲)

提前感谢。

Bjoern

最佳回答

我也许会理解你错误,但我认为应该这样做:

#pragma omp parallel 
{
    unsigned char buffer[1024]; // private

    // while letting each thread process exactly one line in a single run
    #pragma omp for // ... etc
    for(int line = 0; line < max; ++line ) {
          //...
    }
}

如果你真的意味着你要为不同的平行区块分享同样的缓冲,那么你就不得不使用近距离储存。 (Boost and C++11 have facilities for Making that better to do (more portable also) than direct using TlsAlloc和朋友)。

<说明>,这一办法取代方案管理员的一些直线检查负担,因为完全有可能有不同的<条码>并行<<>>部分,同时运行,尤其是在封顶时。

认为平行区块可在运行时铺设,尽管它们不是lexically 封顶。 在实践中,这种做法通常不好,往往导致业绩不佳。 然而,这是你在这样做时需要知道的。

问题回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签