Data Copy in Copy Out
Data Copy in Copy Out
w to copy in the initial value of a private variable to initialize its private copy for each thread in the team.We would also copy out the value of the private variable computed in the last iteration/section to its original variable for the master thread at the end of parallel region.
OpenMP standard provides four clauses
For you to accomplish the data copy in and copy out operations whenever necessary based on your program and parallelization scheme.
!he address computation for each pi&el can be done with the following code( p)est*oc + p,ray - col - row . ,ray"tride' p"rc*oc + p/,0 - col - row . /,0"tride' Improved Version:
1prag2a o2p parallel for private (row3 col) 4 firstprivate(do5nit3 pGray3 p#GB) for ( row = 0; row < height; row++ ) { 66 7eed this init test to +e a+le to start at an 66 ar+itrary point within the i2age after threading$ if (do5nit == !#8") { do5nit = 9:;0"; p#GB += ( row % #GB0tride ); pGray += ( row % Gray0tride ); / for ( col =0; col <width; col++ ) { pGray[col] = (B !") ( p#GB[row]$red % 0$&'' + p#GB[row]$green % 0$()* + p#GB[row]$+l,e % 0$--. ); / pGray += Gray0tride; p#GB += #GB0tride; /