interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / streams / physics-gb10 / gr_info.c

57 lines · 2362 bytes Raw Blame History
1/* gr_info: read-only GB10 inventory through our own path (physics nvrm, open nvidia.ko RM control).
2 * No channel, no allocation, no launch: one RM client, one NV2080_CTRL_CMD_GR_GET_INFO, close.
3 * Index meanings: physics/third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080gr.h.
4 * Build: see build.sh next to this file (PHYSICS_DIR pinned to physics.lock 6d7cf0d4). */
5#include "nvrm.h"
6#include "nvos.h"
7#include "nv-ioctl.h"
8#include "nv-ioctl-numbers.h"
9#include "nv_escape.h"
10#include "ctrl/ctrl2080/ctrl2080gr.h"
11
12#include <stdio.h>
13#include <string.h>
14#include <sys/ioctl.h>
15
16/* same definition as physics nvrm/nvrm.c:48 and forge/forge_descriptor.c:20 */
17#define NV_IOWR(nr, sz) _IOC(_IOC_READ | _IOC_WRITE, NV_IOCTL_MAGIC, (nr), (sz))
18
19#define Q(x) { NV2080_CTRL_GR_INFO_INDEX_##x, #x }
20static const struct { uint32_t index; const char *name; } want[] = {
21 Q(SM_VERSION), Q(SHADER_PIPE_COUNT), Q(SHADER_PIPE_SUB_COUNT), Q(LITTER_NUM_GPCS),
22 Q(LITTER_NUM_TPC_PER_GPC), Q(LITTER_NUM_SM_PER_TPC), Q(MAX_WARPS_PER_SM),
23 Q(MAX_THREADS_PER_WARP), Q(MAX_SP_PER_SM), Q(GPU_CORE_COUNT), Q(SM_REG_BANK_COUNT),
24 Q(SM_REG_BANK_REG_COUNT), Q(LITTER_NUM_LTCS), Q(LITTER_NUM_LTC_SLICES),
25 Q(LITTER_NUM_SLICES_PER_LTC), Q(LITTER_NUM_FBPS),
26};
27#define N (sizeof want / sizeof want[0])
28
29int main(void) {
30 Nvrm rm;
31 memset(&rm, 0, sizeof rm);
32 if (nvrm_open(&rm)) { fprintf(stderr, "nvrm_open failed\n"); return 1; }
33 NV2080_CTRL_GR_INFO list[N];
34 memset(list, 0, sizeof list);
35 for (size_t i = 0; i < N; i++) list[i].index = want[i].index;
36 NV2080_CTRL_GR_GET_INFO_PARAMS gp;
37 memset(&gp, 0, sizeof gp);
38 gp.grInfoListSize = N;
39 gp.grInfoList = (NvP64)(uintptr_t)list;
40 NVOS54_PARAMETERS p;
41 memset(&p, 0, sizeof p);
42 p.hClient = rm.root;
43 p.hObject = rm.subdevice;
44 p.cmd = NV2080_CTRL_CMD_GR_GET_INFO;
45 p.params = (NvP64)(uintptr_t)&gp;
46 p.paramsSize = sizeof gp;
47 int rc = ioctl(rm.fd_ctl, NV_IOWR(NV_ESC_RM_CONTROL, sizeof p), &p);
48 if (rc != 0 || p.status != 0) {
49 fprintf(stderr, "GR_GET_INFO rc %d status 0x%x\n", rc, p.status);
50 nvrm_close(&rm);
51 return 1;
52 }
53 printf("compute_class 0x%x\n", rm.compute_class);
54 for (size_t i = 0; i < N; i++) printf("%s %u\n", want[i].name, list[i].data);
55 nvrm_close(&rm);
56 return 0;
57}