Quantcast
Channel: Parallel Computing in C++ and Native Code forum
Viewing all articles
Browse latest Browse all 856

Nested parallel_for_each or similar constructs

$
0
0

Hi there.

I need to perform an operation as illustrated in the below code. Is there a way to structure this code so that I can call the two operations in some sort of nested p_f_e loops?

I do not want to create a new 2D extent(otherdata.extent,data.extent) in the outer p_f_e loop because that means I have to calculate heavy_calculation 9999 times more than necessary.   

The inside loop now gives "Error: no overload candidate has correct restrict specifiers"

	array_view<const float,1> data(300000, in_data); //in_data has size ~ 300.000 elements
	array_view<const float,1> otherdata(10000, other_in_data); //other_in_data has size ~ 10.000 elements
	parallel_for_each(data.extent, [data,otherdata] (index<1> idx) restrict(amp)
	{
		float TA1[40]; 
		float TA2[40];
		float TA3[40];
		//Do some heavy calculation on each data[idx], 
		//the arrays TA1-3 is updated with new values based on the individual calculations
		heavy_calculation(data[idx],TA1,TA2,TA3); //amp restricted function

		//Next use the calculated TA1,TA2,TA3 and the predefined 
		parallel_for_each(otherdata.extent, [&otherdata,&TA1,&TA2,&TA3] (index<1> idx) restrict(amp)
		{
			//otherdata.extent is around 10.000 elements or more (so I'm inclined to use p_f_e instead of for loop)

			//Do parallel calculation on otherdata here using the calculated TA1-3 (which is similar for each individual data[idx])		
		});
	});


Viewing all articles
Browse latest Browse all 856

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>