{"comment":{"url":"https://api.github.com/repos/Akromx16/gputop/comments/15409772","html_url":"https://github.com/Akromx16/gputop/commit/58d4db26341d92e711add34545762b5c4dd55731#commitcomment-15409772","id":15409772,"user":{"login":"rib","id":235361,"avatar_url":"https://avatars.githubusercontent.com/u/235361?v=3","gravatar_id":"","url":"https://api.github.com/users/rib","html_url":"https://github.com/rib","followers_url":"https://api.github.com/users/rib/followers","following_url":"https://api.github.com/users/rib/following{/other_user}","gists_url":"https://api.github.com/users/rib/gists{/gist_id}","starred_url":"https://api.github.com/users/rib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rib/subscriptions","organizations_url":"https://api.github.com/users/rib/orgs","repos_url":"https://api.github.com/users/rib/repos","events_url":"https://api.github.com/users/rib/events{/privacy}","received_events_url":"https://api.github.com/users/rib/received_events","type":"User","site_admin":false},"position":316,"line":1284,"path":"gputop/gputop-perf.c","commit_id":"58d4db26341d92e711add34545762b5c4dd55731","created_at":"2016-01-12T22:13:40Z","updated_at":"2016-01-12T22:13:40Z","body":"It would be good to move this fake initialization of gputop_devinfo into `init_dev_info()` because as we extend `struct gputop_devinfo` we need to also remember to update this fake initialization which we may easily overlook if it's not all in the same place. The code can be something like...\r\n\r\n```c\r\n// XXX: note that checking gputop_devinfo.n_eus will let us skip re-initializing in the fake case too\r\n// (which won't init intel_dev.device\r\nif (gputop_devinfo.n_eus)\r\n    return true;\r\n\r\nif (getenv(\"GPUTOP_FAKE_MODE\") && strcmp(getenv(\"GPUTOP_FAKE_MODE\"), \"1\") == 0)\r\n    gputop_fake_mode = true;\r\n\r\nif (!gputop_fake_mode) {\r\n    drm_fd = open_render_node(&intel_dev);\r\n    if (drm_fd < 0) {\r\n        ...\r\n    }\r\n}\r\n\r\n// XXX: doesn't matter that these are uninitialized args in fake mode case\r\n// since the implementation can check gputop_fake_mode and not reference\r\n// the drm_fd or the given device id\r\ninit_dev_info(drm_fd, intel_dev.device);\r\npage_size = sysconf(_SC_PAGE_SIZE);\r\n\r\nif (gputop_fake_mode) {\r\n    gputop_oa_add_queries_bdw(&gputop_devinfo);\r\n} else if (IS_HASWELL(intel_dev.device)) {\r\n    ...\r\n} else if (IS_BROADWELL(intel_dev.device)) {\r\n    ...\r\n} else ...\r\n\r\nreturn true;\r\n```"}}