Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int NE = 8;
- int i, j;
- int num_devices = _Offload_number_of_devices();
- // array to be offloaded to the mics
- __declspec(target (mic)) float *offarray = (float*) memalign( 4096, NE * sizeof(float) );
- for ( j = 0; j < NE; j++ ) offarray[j] = sqrt(j);
- // offloat to all (both) mics and retain memory
- for ( i = 0; i < num_devices; i++ )
- {
- #pragma offload_transfer target(mic:i) in ( offarray : length ( NE ) alloc_if(1) free_if(0) )
- }
- // access array on mics in reverse order
- for ( i = num_devices - 1; i >= 0; i-- )
- {
- #pragma offload target(mic:i) nocopy ( offarray )
- {
- int j;
- for ( j = 0; j < NE; j++ ) printf ( "%d(%d) %f\n", j, i, offarray[j] );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement