View difference between Paste ID: CFDmJdHj and u6xAtFFX
SHOW: | | - or go back to the newest paste.
1
	int NE = 8;
2
	int i, j;
3
	
4-
	nt num_devices = _Offload_number_of_devices();
4+
	int num_devices = _Offload_number_of_devices();
5
6
	// array to be offloaded to the mics
7
	__declspec(target (mic)) float *offarray = (float*) memalign( 4096, NE * sizeof(float) );
8
	for ( j = 0; j < NE; j++ ) offarray[j] = sqrt(j);
9
10
11
	// offloat to all (both) mics and retain memory
12
	for ( i = 0; i < num_devices; i++ )
13
	{
14
		#pragma offload_transfer target(mic:i) in ( offarray : length ( NE ) alloc_if(1) free_if(0) )
15
	}
16
17
	// access array on mics in reverse order
18
	for ( i = num_devices - 1; i >= 0; i-- )
19
	{
20
		#pragma offload target(mic:i) nocopy ( offarray )
21
		{
22
			int j;
23
			for ( j = 0; j < NE; j++ ) printf ( "%d(%d) %f\n", j, i, offarray[j] );
24
		}
25
	}