• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #undef NDEBUG
2 
3 #include <assert.h>
4 
5 #include "intel_device_info.h"
6 
7 static void
verify_device_info(const struct intel_device_info * devinfo)8 verify_device_info(const struct intel_device_info *devinfo)
9 {
10    assert(devinfo->ver != 0);
11    assert((devinfo->verx10 / 10) == devinfo->ver);
12    assert(devinfo->max_eus_per_subslice != 0);
13    assert(devinfo->num_thread_per_eu != 0);
14    assert(devinfo->timestamp_frequency != 0);
15    assert(devinfo->cs_prefetch_size > 0);
16 
17    assert(devinfo->ver < 7 || devinfo->max_constant_urb_size_kb > 0);
18    assert(devinfo->ver < 8 || devinfo->max_threads_per_psd > 0);
19 
20    assert(devinfo->platform >= 1);
21 
22    assert(devinfo->num_slices <= ARRAY_SIZE(devinfo->subslice_masks));
23 
24    assert(devinfo->num_slices <= devinfo->max_slices);
25    assert(intel_device_info_subslice_total(devinfo) <=
26           (devinfo->max_slices * devinfo->max_subslices_per_slice));
27 
28    for (uint32_t s = 0; s < ARRAY_SIZE(devinfo->num_subslices); s++)
29       assert(devinfo->num_subslices[s] <= devinfo->max_subslices_per_slice);
30 
31    assert(__builtin_popcount(devinfo->slice_masks) <= devinfo->max_slices);
32 
33    uint32_t total_subslices = 0;
34    for (size_t i = 0; i < ARRAY_SIZE(devinfo->subslice_masks); i++)
35       total_subslices += __builtin_popcount(devinfo->subslice_masks[i]);
36    assert(total_subslices <=
37           (devinfo->max_slices * devinfo->max_subslices_per_slice));
38 
39    assert(intel_device_info_eu_total(devinfo) > 0);
40    assert(intel_device_info_subslice_total(devinfo) > 0);
41 
42    total_subslices = 0;
43    for (uint32_t s = 0; s < devinfo->max_slices; s++)
44       for (uint32_t ss = 0; ss < devinfo->max_subslices_per_slice; ss++)
45          total_subslices += intel_device_info_subslice_available(devinfo, s, ss);
46    assert(total_subslices == intel_device_info_subslice_total(devinfo));
47 
48    uint32_t total_eus = 0;
49    for (uint32_t s = 0; s < devinfo->max_slices; s++)
50       for (uint32_t ss = 0; ss < devinfo->max_subslices_per_slice; ss++)
51          for (uint32_t eu = 0; eu < devinfo->max_eus_per_subslice; eu++)
52             total_eus += intel_device_info_eu_available(devinfo, s, ss, eu);
53    assert(total_eus == intel_device_info_eu_total(devinfo));
54 }
55