Skip to content

CUDA: Add optional Driver API argument logging - #6798

Merged
sklam merged 1 commit into
numba:masterfrom
gmarkall:grm-cuda-api-logs
Mar 8, 2021
Merged

sklam merged 1 commit into
numba:masterfrom
gmarkall:grm-cuda-api-logs

Conversation

@gmarkall

@gmarkall gmarkall commented Mar 5, 2021

Copy link
Copy Markdown
Member

(Background: I often find myself making a temporary change like this locally, but I think being able to turn this on and off generally would be useful, and I'm also fed up of applying / reverting a change like this to my local repo :-) )

Setting the config variable CUDA_LOG_API_ARGS enables logging of Driver API function arguments in the CUDA logs.

This commit also documents this variable along with the CUDA_LOG_LEVEL config variable.

Without the API argument logging, logs look like (for example):

$ NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from numba import cuda; cuda.device_array(1)"
== CUDA [237]  INFO -- init
== CUDA [238] DEBUG -- call driver api: cuInit
== CUDA [275] DEBUG -- call driver api: cuCtxGetCurrent
== CUDA [275] DEBUG -- call driver api: cuCtxGetCurrent
== CUDA [275] DEBUG -- call driver api: cuDeviceGetCount
== CUDA [275] DEBUG -- call driver api: cuDeviceGet
== CUDA [275] DEBUG -- call driver api: cuDeviceComputeCapability
== CUDA [275] DEBUG -- call driver api: cuDeviceGetName
== CUDA [275] DEBUG -- call driver api: cuDeviceGetUuid
== CUDA [275] DEBUG -- call driver api: cuDeviceGet
== CUDA [275] DEBUG -- call driver api: cuDeviceComputeCapability
== CUDA [275] DEBUG -- call driver api: cuDeviceGetName
== CUDA [275] DEBUG -- call driver api: cuDeviceGetUuid
== CUDA [276] DEBUG -- call driver api: cuDevicePrimaryCtxRetain
== CUDA [370] DEBUG -- call driver api: cuCtxPushCurrent_v2
== CUDA [370] DEBUG -- call driver api: cuMemGetInfo_v2
== CUDA [371] DEBUG -- call driver api: cuMemAlloc_v2
== CUDA [371]  INFO -- add pending dealloc: cuMemFree_v2 8 bytes

With API argument logging, this becomes:

$ NUMBA_CUDA_LOG_API_ARGS=1 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from numba import cuda; cuda.device_array(1)"
== CUDA [242]  INFO -- init
== CUDA [242] DEBUG -- call driver api: cuInit(0)
== CUDA [276] DEBUG -- call driver api: cuCtxGetCurrent(<cparam 'P' (0x7ff5954c9310)>)
== CUDA [276] DEBUG -- call driver api: cuCtxGetCurrent(<cparam 'P' (0x7ff5954c9310)>)
== CUDA [276] DEBUG -- call driver api: cuDeviceGetCount(<cparam 'P' (0x7ff5954c9310)>)
== CUDA [276] DEBUG -- call driver api: cuDeviceGet(<cparam 'P' (0x7ff5954c9310)>, 0)
== CUDA [276] DEBUG -- call driver api: cuDeviceComputeCapability(<cparam 'P' (0x7ff5953faa90)>, <cparam 'P' (0x7ff5953fa990)>, 0)
== CUDA [277] DEBUG -- call driver api: cuDeviceGetName(<numba.cuda.cudadrv.driver.c_char_Array_128 object at 0x7ff5953fabc0>, 128, 0)
== CUDA [277] DEBUG -- call driver api: cuDeviceGetUuid(<cparam 'P' (0x7ff5953fad90)>, 0)
== CUDA [277] DEBUG -- call driver api: cuDeviceGet(<cparam 'P' (0x7ff5954c9310)>, 1)
== CUDA [277] DEBUG -- call driver api: cuDeviceComputeCapability(<cparam 'P' (0x7ff5953fad10)>, <cparam 'P' (0x7ff5953fad90)>, 1)
== CUDA [277] DEBUG -- call driver api: cuDeviceGetName(<numba.cuda.cudadrv.driver.c_char_Array_128 object at 0x7ff5953fabc0>, 128, 1)
== CUDA [277] DEBUG -- call driver api: cuDeviceGetUuid(<cparam 'P' (0x7ff5953faa90)>, 1)
== CUDA [277] DEBUG -- call driver api: cuDevicePrimaryCtxRetain(<cparam 'P' (0x7ff5954c9310)>, 0)
== CUDA [367] DEBUG -- call driver api: cuCtxPushCurrent_v2(c_void_p(94307166233376))
== CUDA [367] DEBUG -- call driver api: cuMemGetInfo_v2(<cparam 'P' (0x7ff5953fa990)>, <cparam 'P' (0x7ff5953faa90)>)
== CUDA [367] DEBUG -- call driver api: cuMemAlloc_v2(<cparam 'P' (0x7ff5953d3310)>, 8)
== CUDA [367]  INFO -- add pending dealloc: cuMemFree_v2 8 bytes

Setting the config variable `CUDA_LOG_API_ARGS` enables logging of
Driver API function arguments in the CUDA logs.

This commit also documents this variable along with the CUDA_LOG_LEVEL
config variable.

Without the API argument logging, logs look like (for example):

```
$ NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from numba import cuda; cuda.device_array(1)"
== CUDA [237]  INFO -- init
== CUDA [238] DEBUG -- call driver api: cuInit
== CUDA [275] DEBUG -- call driver api: cuCtxGetCurrent
== CUDA [275] DEBUG -- call driver api: cuCtxGetCurrent
== CUDA [275] DEBUG -- call driver api: cuDeviceGetCount
== CUDA [275] DEBUG -- call driver api: cuDeviceGet
== CUDA [275] DEBUG -- call driver api: cuDeviceComputeCapability
== CUDA [275] DEBUG -- call driver api: cuDeviceGetName
== CUDA [275] DEBUG -- call driver api: cuDeviceGetUuid
== CUDA [275] DEBUG -- call driver api: cuDeviceGet
== CUDA [275] DEBUG -- call driver api: cuDeviceComputeCapability
== CUDA [275] DEBUG -- call driver api: cuDeviceGetName
== CUDA [275] DEBUG -- call driver api: cuDeviceGetUuid
== CUDA [276] DEBUG -- call driver api: cuDevicePrimaryCtxRetain
== CUDA [370] DEBUG -- call driver api: cuCtxPushCurrent_v2
== CUDA [370] DEBUG -- call driver api: cuMemGetInfo_v2
== CUDA [371] DEBUG -- call driver api: cuMemAlloc_v2
== CUDA [371]  INFO -- add pending dealloc: cuMemFree_v2 8 bytes
```

With API argument logging, this becomes:

```
$ NUMBA_CUDA_LOG_API_ARGS=1 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from numba import cuda; cuda.device_array(1)"
== CUDA [242]  INFO -- init
== CUDA [242] DEBUG -- call driver api: cuInit(0)
== CUDA [276] DEBUG -- call driver api: cuCtxGetCurrent(<cparam 'P' (0x7ff5954c9310)>)
== CUDA [276] DEBUG -- call driver api: cuCtxGetCurrent(<cparam 'P' (0x7ff5954c9310)>)
== CUDA [276] DEBUG -- call driver api: cuDeviceGetCount(<cparam 'P' (0x7ff5954c9310)>)
== CUDA [276] DEBUG -- call driver api: cuDeviceGet(<cparam 'P' (0x7ff5954c9310)>, 0)
== CUDA [276] DEBUG -- call driver api: cuDeviceComputeCapability(<cparam 'P' (0x7ff5953faa90)>, <cparam 'P' (0x7ff5953fa990)>, 0)
== CUDA [277] DEBUG -- call driver api: cuDeviceGetName(<numba.cuda.cudadrv.driver.c_char_Array_128 object at 0x7ff5953fabc0>, 128, 0)
== CUDA [277] DEBUG -- call driver api: cuDeviceGetUuid(<cparam 'P' (0x7ff5953fad90)>, 0)
== CUDA [277] DEBUG -- call driver api: cuDeviceGet(<cparam 'P' (0x7ff5954c9310)>, 1)
== CUDA [277] DEBUG -- call driver api: cuDeviceComputeCapability(<cparam 'P' (0x7ff5953fad10)>, <cparam 'P' (0x7ff5953fad90)>, 1)
== CUDA [277] DEBUG -- call driver api: cuDeviceGetName(<numba.cuda.cudadrv.driver.c_char_Array_128 object at 0x7ff5953fabc0>, 128, 1)
== CUDA [277] DEBUG -- call driver api: cuDeviceGetUuid(<cparam 'P' (0x7ff5953faa90)>, 1)
== CUDA [277] DEBUG -- call driver api: cuDevicePrimaryCtxRetain(<cparam 'P' (0x7ff5954c9310)>, 0)
== CUDA [367] DEBUG -- call driver api: cuCtxPushCurrent_v2(c_void_p(94307166233376))
== CUDA [367] DEBUG -- call driver api: cuMemGetInfo_v2(<cparam 'P' (0x7ff5953fa990)>, <cparam 'P' (0x7ff5953faa90)>)
== CUDA [367] DEBUG -- call driver api: cuMemAlloc_v2(<cparam 'P' (0x7ff5953d3310)>, 8)
== CUDA [367]  INFO -- add pending dealloc: cuMemFree_v2 8 bytes
```
@gmarkall gmarkall added 2 - In Progress CUDA CUDA related issue/PR 3 - Ready for Review Effort - short Short size effort needed and removed 2 - In Progress labels Mar 5, 2021
@stuartarchibald stuartarchibald added Pending BuildFarm For PRs that have been reviewed but pending a push through our buildfarm 4 - Waiting on CI Review etc done, waiting for CI to finish and removed 3 - Ready for Review labels Mar 8, 2021

@stuartarchibald stuartarchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

@stuartarchibald stuartarchibald added this to the Numba 0.54 RC milestone Mar 8, 2021
@stuartarchibald

Copy link
Copy Markdown
Contributor

Note: I tested this manually to confirm both the presented debug changes.

@stuartarchibald

Copy link
Copy Markdown
Contributor

Buildfarm ID: numba_smoketest_cuda_yaml_21.

@stuartarchibald

Copy link
Copy Markdown
Contributor

Buildfarm ID: numba_smoketest_cuda_yaml_21.

Passed.

@stuartarchibald stuartarchibald added 5 - Ready to merge Review and testing done, is ready to merge BuildFarm Passed For PRs that have been through the buildfarm and passed and removed 4 - Waiting on CI Review etc done, waiting for CI to finish Pending BuildFarm For PRs that have been reviewed but pending a push through our buildfarm labels Mar 8, 2021
@sklam
sklam merged commit bdb5f29 into numba:master Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Review and testing done, is ready to merge BuildFarm Passed For PRs that have been through the buildfarm and passed CUDA CUDA related issue/PR Effort - short Short size effort needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants