14
14
15
15
import org .junit .*;
16
16
17
- import com .nativelibs4java .test .MiscTestUtils ;
18
17
import com .nativelibs4java .util .NIOUtils ;
19
18
import org .bridj .*;
20
19
import java .nio .ByteOrder ;
21
20
import static org .bridj .Pointer .*;
22
21
import java .nio .ByteOrder ;
23
- import java .util .List ;
22
+ import java .util .*;
23
+ import org .junit .runner .RunWith ;
24
24
import org .junit .runners .Parameterized ;
25
25
26
26
/**
27
27
*
28
28
* @author ochafik
29
29
*/
30
- public class DeviceTest extends AbstractCommon {
30
+ @ RunWith (Parameterized .class )
31
+ public class DeviceTest {
32
+ private final CLDevice device ;
33
+
31
34
public DeviceTest (CLDevice device ) {
32
- super (device );
35
+ this .device = device ;
36
+
37
+ System .out .println (device );
38
+ System .out .println ("\t max sub-devices: " + device .getPartitionMaxSubDevices ());
39
+ System .out .println ("\t partition properties: " + device .getPartitionProperties ());
33
40
}
34
41
35
42
@ Parameterized .Parameters
36
43
public static List <Object []> getDeviceParameters () {
37
- return AbstractCommon .getDeviceParameters ();
44
+ List <Object []> ret = new ArrayList <Object []>();
45
+ for (CLPlatform platform : JavaCL .listPlatforms ()) {
46
+ for (CLDevice device : platform .listAllDevices (true )) {
47
+ ret .add (new Object [] { device });
48
+ }
49
+ }
50
+ return ret ;
38
51
}
39
- @ Ignore
52
+
40
53
@ Test
41
54
public void testSplitEqually () {
55
+ if (!device .getPartitionProperties ().contains (CLDevice .PartitionType .Equally )) return ;
56
+
42
57
int computeUnits = device .getMaxComputeUnits ();
43
58
System .out .println ("computeUnits = " + computeUnits );
44
- int subComputeUnits = 1 ; // computeUnits / 2;
59
+ int subComputeUnits = computeUnits / 2 ;
45
60
46
61
CLDevice [] subDevices = device .createSubDevicesEqually (subComputeUnits );
47
62
for (CLDevice subDevice : subDevices ) {
48
63
assertEquals (subComputeUnits , subDevice .getMaxComputeUnits ());
49
64
checkParent (device , subDevice );
50
65
}
51
66
}
52
- @ Ignore
67
+
53
68
@ Test
54
69
public void testSplitByCounts () {
70
+ if (!device .getPartitionProperties ().contains (CLDevice .PartitionType .ByCounts )) return ;
71
+
55
72
long [] counts = new long [] { 2 , 4 , 8 };
56
73
CLDevice [] subDevices = device .createSubDevicesByCounts (counts );
57
74
assertEquals (counts .length , subDevices .length );
@@ -63,9 +80,11 @@ public void testSplitByCounts() {
63
80
i ++;
64
81
}
65
82
}
66
- @ Ignore
83
+
67
84
@ Test
68
85
public void testSplitByAffinity () {
86
+ if (!device .getPartitionProperties ().contains (CLDevice .PartitionType .ByAffinityDomain )) return ;
87
+
69
88
CLDevice [] subDevices = device .createSubDevicesByAffinity (CLDevice .AffinityDomain .NextPartitionable );
70
89
assertTrue (subDevices .length > 1 );
71
90
for (CLDevice subDevice : subDevices ) {
@@ -76,7 +95,7 @@ public void testSplitByAffinity() {
76
95
private void checkParent (CLDevice parent , CLDevice child ) {
77
96
assertSame (device , child .getParent ());
78
97
// Force a get info CL_DEVICE_PARENT_DEVICE.
79
- assertSame (device , new CLDevice (platform , null , child .getEntity (), false ).getParent ());
98
+ assertSame (device , new CLDevice (device . getPlatform () , null , child .getEntity (), false ).getParent ());
80
99
}
81
100
82
101
}
0 commit comments