1#undef NDEBUG
2
3#include <stdint.h>
4#include <assert.h>
5
6#include "intel_device_info.h"
7
8int
9main(int argc, char *argv[])
10{
11   struct {
12      uint32_t pci_id;
13      const char *name;
14   } chipsets[] = {
15#undef CHIPSET
16#define CHIPSET(id, family, family_str, str_name) { .pci_id = id, .name = str_name, },
17#include "pci_ids/i965_pci_ids.h"
18#include "pci_ids/iris_pci_ids.h"
19   };
20
21   for (uint32_t i = 0; i < ARRAY_SIZE(chipsets); i++) {
22      struct intel_device_info devinfo = { 0, };
23
24      assert(intel_get_device_info_from_pci_id(chipsets[i].pci_id, &devinfo));
25
26      assert(devinfo.ver != 0);
27      assert(devinfo.num_eu_per_subslice != 0);
28      assert(devinfo.num_thread_per_eu != 0);
29      assert(devinfo.timestamp_frequency != 0);
30      assert(devinfo.cs_prefetch_size > 0);
31
32      assert(devinfo.ver < 7 || devinfo.max_constant_urb_size_kb > 0);
33
34      assert(devinfo.num_slices <= ARRAY_SIZE(devinfo.subslice_masks));
35
36      assert(devinfo.num_slices <= devinfo.max_slices);
37      assert(intel_device_info_subslice_total(&devinfo) <=
38             (devinfo.max_slices * devinfo.max_subslices_per_slice));
39
40      for (uint32_t s = 0; s < ARRAY_SIZE(devinfo.num_subslices); s++)
41         assert(devinfo.num_subslices[s] <= devinfo.max_subslices_per_slice);
42
43      assert(__builtin_popcount(devinfo.slice_masks) <= devinfo.max_slices);
44
45      uint32_t total_subslices = 0;
46      for (size_t i = 0; i < ARRAY_SIZE(devinfo.subslice_masks); i++)
47         total_subslices += __builtin_popcount(devinfo.subslice_masks[i]);
48      assert(total_subslices <=
49             (devinfo.max_slices * devinfo.max_subslices_per_slice));
50
51      assert(intel_device_info_eu_total(&devinfo) > 0);
52      assert(intel_device_info_subslice_total(&devinfo) > 0);
53
54      total_subslices = 0;
55      for (uint32_t s = 0; s < devinfo.max_slices; s++)
56         for (uint32_t ss = 0; ss < devinfo.max_subslices_per_slice; ss++)
57            total_subslices += intel_device_info_subslice_available(&devinfo, s, ss);
58      assert(total_subslices == intel_device_info_subslice_total(&devinfo));
59
60      uint32_t total_eus = 0;
61      for (uint32_t s = 0; s < devinfo.max_slices; s++)
62         for (uint32_t ss = 0; ss < devinfo.max_subslices_per_slice; ss++)
63            for (uint32_t eu = 0; eu < devinfo.max_eu_per_subslice; eu++)
64               total_eus += intel_device_info_eu_available(&devinfo, s, ss, eu);
65      assert(total_eus == intel_device_info_eu_total(&devinfo));
66   }
67
68   return 0;
69}
70