TechArena Community How can I use parallel_for to pass two dimensional arrays

#1
06-10-2010
 Member Join Date: Apr 2010 Posts: 182
How can I use parallel_for to pass two dimensional arrays

I tried to utilize parallel_for to velocity up our c++ program. It seems extremely simple to utilize. On the other hand, in the purpose which is to be parallelized, a small number of 2D arrays calculated in the function necessitate be passed to the most important function. In the illustration (sub_string_finder.cpp), one dimensional array is customized in the Sub String Finder by using the addresses of these arrays. Give pleasure to observe the code beneath. I am wondering if I be able to utilize similar trick, additional than not certain how to utilize it on 2D arrays. I originate a method to get around the tribulations. Immediately pass one dimensional arrays and renovate them to two dimensional arrays later.
#2
06-10-2010
 Member Join Date: Apr 2009 Posts: 567
Re: How can I use parallel_for to pass two dimensional arrays

Might anybody demonstrate me how to put into practice two-dimensional matrix multiplication by means of changeable size 2D arrays. The illustration demonstrates in Intel TBB book uses fixed size arrays. Demonstrations of 2D variable-size matrices extremely widely in C++. If you sketch your favorite approach for serial duplication of variable-size matrices, then perhaps an important person be able to position the TBBified version or description.
#3
06-10-2010
 Member Join Date: May 2009 Posts: 525
Re: How can I use parallel_for to pass two dimensional arrays

At this point is the regulations from Intel TBB book that I have comprised and modified to utilize Numerical Recipe C++ matrix class, Mat_SP (matrix solitary precision). The regulations compiles and executes, additional than calculations from serial and parallel section of the code do not match. I imagine the code utilizing NR pass in matrix data ok additional than having tribulations returning matrix data back to the most important program. Your assist is to a great extent appreciated! I imagine the tribulations happens within operator () code (i.e, Mat_SP c = my_c, this generates an innovative copy of matrix c as an alternative of the original matrix c; I encompass no idea how to pass this innovative copy of the matrix c back to the most important program).
#4
06-10-2010
 Member Join Date: May 2009 Posts: 620
Re: How can I use parallel_for to pass two dimensional arrays

I had tested this morning at work, the innovative version or description of my submission utilizing tbbmalloc.dll run twice as fast as my duo core laptop. I accumulated the application utilizing ms visual studio 2005 professional (I deduction their memory distribution routine is not optimal for parallel processing.) By means of auto portioned grain size. Btw even on solitary processor apparatus, TBB essentially speeds up the application.
#5
06-10-2010
 Member Join Date: May 2009 Posts: 533
Re: How can I use parallel_for to pass two dimensional arrays

The 2D matrix multiplication submission was immediately my testing to get acquainted by means of TBB library. The authentic submission I am running on is essentially a 2D SAR (synthetic aperture radar) polar reformat submission that computes 2D interpolations for data matrices as large as 2048x2048, for a moment larger. It has two for loops by means of 2d interpolations completed within inner loop. I am experimenting by means of dissimilar grain size to observe if it would further speed up the processing.
#6
06-10-2010
 vincomgo Posts: n/a
Re: How can I use parallel_for to pass two dimensional arrays

I agree w u Steyn .I dont think that it's good enough.How about the larger size=.=
#7
07-10-2010
 Member Join Date: Apr 2010 Posts: 218
Re: How can I use parallel_for to pass two dimensional arrays

The entire workers accomplish a parfor-loop must have encompassed the similar MATLAB path arrangement as the client, so that they be able to implement several functions called in the body of the loop. Consequently, whenever you utilize cd, addpath, or rmpath on the client, it in addition executes on the entire the workers, if probable. For additional information in sequence, observe the matlabpool reference page. When the workers are working with on a dissimilar platform than the client, utilize the function pctRunOnAll to appropriately set the MATLAB path on the entire workers.
#8
08-10-2010
 Member Join Date: Mar 2010 Posts: 576
Re: How can I use parallel_for to pass two dimensional arrays

If you utilize a name that MATLAB not be able to unmistakably distinguish as a changeable inside a parfor-loop, at parse time MATLAB take for granted you are referencing a function. Then at run-time, if the function not be able to be originate, MATLAB generates an error. (Observe Naming Variables in the MATLAB certification.) For illustration, in the subsequent code f (5) might refer moreover to the fifth component of an array named f, or to a function named f by means of an argument of 5. If f is not obviously defined as a changeable in the code, MATLAB give the impression of being for the function f on the path when the code runs.

 Tags: