[Mesa-dev] [PATCH shaderdb 2/3] run: new '--pci-id' option for overriding pci-id
Dongwon Kim
dongwon.kim at intel.com
Tue Feb 13 01:26:15 UTC 2018
Add a new option, '--pciid' to override a pci id of the target arch
to support cross-architecture shader compilation. Not like "-p" option,
it is for accepting any GFX devices supported by the driver.
Setting both "-p" and "--pciid" is blocked to avoid conflict.
Signed-off-by: Dongwon Kim <dongwon.kim at intel.com>
---
run.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/run.c b/run.c
index 23d2b07..d066567 100644
--- a/run.c
+++ b/run.c
@@ -36,6 +36,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
+#include <getopt.h>
+#include <limits.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -353,10 +355,21 @@ const struct platform platforms[] = {
"skl", "0x191D",
};
+enum
+{
+ PCI_ID_OVERRIDE_OPTION = CHAR_MAX + 1,
+};
+
+const struct option const long_options[] =
+{
+ {"pciid", required_argument, NULL, PCI_ID_OVERRIDE_OPTION},
+ {NULL, 0, NULL, 0}
+};
+
void print_usage(const char *prog_name)
{
fprintf(stderr,
- "Usage: %s [-d <device>] [-j <max_threads>] [-o <driver>] [-p <platform>] <directories and *.shader_test files>\n",
+ "Usage: %s [-d <device>] [-j <max_threads>] [-o <driver>] [-p <platform>] [--pciid=<chip id of targetted gen arch>] <directories and *.shader_test files>\n",
prog_name);
}
@@ -435,10 +448,13 @@ main(int argc, char **argv)
char device_path[64];
int device_id = 0;
int opt;
+ bool platf_overridden = 0;
+ bool pci_id_overridden = 0;
max_threads = omp_get_max_threads();
- while ((opt = getopt(argc, argv, "d:j:o:p:")) != -1) {
+ while ((opt = getopt_long(argc, argv, "d:j:o:p:",
+ long_options, NULL)) != -1) {
switch(opt) {
case 'd': {
char *endptr;
@@ -456,6 +472,13 @@ main(int argc, char **argv)
break;
case 'p': {
const struct platform *platform = NULL;
+
+ if (pci_id_overridden) {
+ unsetenv("INTEL_DEVID_OVERRIDE");
+ fprintf(stderr, "'-p' and '--pciid' can't be used together.\n");
+ return -1;
+ }
+
for (unsigned i = 0; i < ARRAY_SIZE(platforms); i++) {
if (strcmp(optarg, platforms[i].name) == 0) {
platform = platforms + i;
@@ -473,11 +496,28 @@ main(int argc, char **argv)
printf("### Compiling for %s ###\n", platform->name);
setenv("INTEL_DEVID_OVERRIDE", platform->pci_id, 1);
+ platf_overridden = 1;
break;
}
case 'j':
max_threads = atoi(optarg);
break;
+ case PCI_ID_OVERRIDE_OPTION:
+ if (platf_overridden) {
+ unsetenv("INTEL_DEVID_OVERRIDE");
+ fprintf(stderr, "'-p' and '--pciid' can't be used together.\n");
+ return -1;
+ }
+
+ if (optarg[0] != '0' || optarg[1] != 'x') {
+ fprintf(stderr, "pci-id should be a hex number starting with '0x'\n");
+ return -1;
+ }
+
+ printf("### Compiling for GEN arch with PCI_ID=%s ###\n", optarg);
+ setenv("INTEL_DEVID_OVERRIDE", optarg, 1);
+ pci_id_overridden = 1;
+ break;
default:
fprintf(stderr, "Unknown option: %x\n", opt);
print_usage(argv[0]);
--
2.16.1
More information about the mesa-dev
mailing list