Comments (5)
Hello @YixinSong-e , thank you for your interest.
Explanation follows, but as you read it please bear in mind:
- Same files published here are used by other NVIDIA code, including Windows driver and various microcodes
- Many of the design decisions come with over 20 years of history
What I'm saying is, anyone reading the code here and my explanation will rightly think "why!?", but I'm asking you to trust me that it makes (more) sense with context :)
Anyway, NVOC stands for "NVIDIA Object Compiler" and it is effectively a preprocessor that allows us to have some syntax sugar in our headers. Practically what it does is allow us to annotate some "methods" of an "object" in ways that later allow for lookups or feature toggle flags, or define per-chip specific behaviors.
This isn't used very much in the current codebase, but once you have a nice hammer a lot of things can be made into a compatible nail, so we have a lot of "objects" that use NVOC. How it typically works is that we have an NVOC-enabled header, like system.h
which contains annotated C code. Then, the code is preprocessed and NVOC produces g_system_nvoc.{h,c}
files. The .c file is included in the build, and system.h
is redirected into g_system_nvoc.h
.
Most common use here is to annotate "control" methods that are exposed by the kernel driver to usermode. Think of it as a way to annotate ioctl() handlers and have a preprocessor generate the plumbing that dispatches to the correct function based on ioctl command ID.
As you can imagine, this complicates the build process significantly, so we have decided it is better for everyone involved if we just ran NVOC once and published the generated files. This way we didn't have to require custom tooling which would make compiling this project a nightmare.
In the future we hope to modify the tool so that the generated code is more readable and less noisy.
I hope this helps. Please feel free to ask about any specifics.
from open-gpu-kernel-modules.
Thank you for your detailed reply, your explanation helped me a lot in understanding the driver code.π
from open-gpu-kernel-modules.
Are NVOC code generator source code published somewhere?
They are not. I doubt it would be of any use to anyone else other than to satisfy curiosity, and unfortunately there is a cost with open sourcing anything developed internally. We feel those resources are better spent on improving the published code.
For what it's worth, it is a fork of clang 3.x, extended to understand some custom syntax and produce C output. If you're particularly curious, I can give an example input and output that it produces so you have an idea on what you're missing out on.
from open-gpu-kernel-modules.
Are NVOC code generator source code published somewhere?
from open-gpu-kernel-modules.
Closing this, let's use #148 to consolidate all similar questions. Thanks!
from open-gpu-kernel-modules.
Related Issues (20)
- Can't compile with DEBUG flag set on 535.86.05 (error: unknown type name βclassβ) HOT 4
- NVIDIA VGPU does not work HOT 9
- building main against current centos stream 8 fails HOT 3
- nvidia-smi -gtt doesn't work HOT 5
- allow a way to specify the kernel HOT 1
- Error! Bad return status for module build on kernel: 6.5.2-arch1-1 (x86_64) HOT 10
- extract-firmware-nouveau.py creates wrong file names HOT 1
- Rocky Linux 8.8 crash HOT 3
- eGPU kernel modules failure - Chipset Setup Function Error! HOT 3
- Wrong version tag? HOT 2
- 545.29.02 VRR HDMI 100% broken HOT 14
- No video after waking after screen evergy saving mode (KDE Plasma) HOT 3
- The brightness control of NVIDIA seems to be broken HOT 11
- crypto_shash_ctx_aligned has been removed from the linux kernel in the linux-next version HOT 2
- libGL error: failed to load driver iris; failed to load driver swrast HOT 4
- RMAPI_GPU_LOCK_INTERNAL alloc requested without holding the RMAPI lock HOT 6
- Can't build nvidia driver on Linux 4.19 (Ubuntu 20.04) HOT 2
- Invalid pointer free HOT 3
- failed to build on RHEL 8.4 HOT 1
- Installing the NVIDIA Driver and CUDA Toolkit failed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open-gpu-kernel-modules.