@@ -81,6 +81,48 @@ def test_create_program_from_spirv(self):
81
81
self .assertEqual (addKernel .get_num_args (), 3 )
82
82
self .assertEqual (axpyKernel .get_num_args (), 4 )
83
83
84
+ @unittest .skipUnless (
85
+ dpctl .has_gpu_queues (backend_ty = dpctl .backend_type .opencl ),
86
+ "No Level0 GPU queues available"
87
+ )
88
+ class TestProgramForLevel0GPU (unittest .TestCase ):
89
+
90
+ def test_create_program_from_spirv (self ):
91
+
92
+ CURR_DIR = os .path .dirname (os .path .abspath (__file__ ))
93
+ spirv_file = os .path .join (CURR_DIR , 'input_files/multi_kernel.spv' )
94
+ with open (spirv_file , 'rb' ) as fin :
95
+ spirv = fin .read ()
96
+ with dpctl .device_context ("level0:gpu:0" ):
97
+ q = dpctl .get_current_queue ()
98
+ try :
99
+ prog = dpctl .create_program_from_spirv (q ,spirv )
100
+ self .fail (
101
+ "Tried to create program for an unsupported Level0 GPU."
102
+ )
103
+ except ValueError :
104
+ pass
105
+
106
+ def test_create_program_from_source (self ):
107
+ oclSrc = " \
108
+ kernel void add(global int* a, global int* b, global int* c) { \
109
+ size_t index = get_global_id(0); \
110
+ c[index] = a[index] + b[index]; \
111
+ } \
112
+ kernel void axpy(global int* a, global int* b, global int* c, int d) { \
113
+ size_t index = get_global_id(0); \
114
+ c[index] = a[index] + d*b[index]; \
115
+ }"
116
+ with dpctl .device_context ("level0:gpu:0" ):
117
+ q = dpctl .get_current_queue ()
118
+ try :
119
+ prog = dpctl .create_program_from_source (q , oclSrc )
120
+ self .fail (
121
+ "Tried to create program for an unsupported Level0 GPU."
122
+ )
123
+ except ValueError :
124
+ pass
125
+
84
126
85
127
if __name__ == '__main__' :
86
128
unittest .main ()
0 commit comments