Skip to content

Commit

Permalink
CUDA profiling scaffolding with nvtx (#491)
Browse files Browse the repository at this point in the history
Summary:
Introduce a new profiling framework for the CUDA backend. Uses NVTX (https://docs.nvidia.com/nsight-visual-studio-edition/nvtx/index.html) -- finds and links the lib/headers. NVTX provides integration with Nsight profiling tools, which I'll give more details about soon.

Docs forthcoming in a future diff.

Compile with `FL_BUILD_PROFILING=ON` to build profiling things. `OFF` by default. CUDA backend only. We can add CPU profiling in an unopinionated way whenever we're ready.

[Note -- this doesn't build right now since `CudaUtils.*` isn't moved - this will happen in a follow-up diff/commit to fix the fbcode build]

### Usage:

RAII shims that call into CUDA NVTX profile start/stop marking functions:
- `FL_SCOPED_PROFILE()` starts and stops profiling. This will help keep the size of our profiles small and high-signal and speed up execution speed given we can avoid more profiling overhead.
- `FL_PROFILE_TRACE("myMarker")` -- marks a code section with a particular marker string. RAII -- only marks the section while in scope. Best used when profiling a function.

Pull Request resolved: flashlight/flashlight#491

Test Plan: Tested with Nsight profilers with a transformer benchmark. Tutorial and more documentation on how to get these running is forthcoming.

Reviewed By: padentomasello

Differential Revision: D26929884

Pulled By: jacobkahn

fbshipit-source-id: 3d79ebcf9617587b68411725c028bdd94309996f
  • Loading branch information
jacobkahn authored and facebook-github-bot committed Mar 17, 2021
1 parent ed4643e commit 0bf8752
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ else ()
message(FATAL_ERROR "Invalid FLASHLIGHT backend specified")
endif ()

# Profiling
# TODO: for now, profiling is only enabled with the CUDA backend -
# can enable other profiling once an implementation is in place
cmake_dependent_option(FL_BUILD_PROFILING
"Enable profiling with Flashlight" OFF
"FL_USE_CUDA" OFF)

# List of installable targets
set(INSTALLABLE_TARGETS "")

Expand Down Expand Up @@ -253,6 +260,7 @@ if (FL_BUILD_CORE)
FL_BACKEND_CPU=$<BOOL:${FL_USE_CPU}>
FL_BACKEND_CUDA=$<BOOL:${FL_USE_CUDA}>
FL_BACKEND_OPENCL=$<BOOL:${FL_USE_OPENCL}>
FL_BUILD_PROFILING=$<BOOL:${FL_BUILD_PROFILING}>
)

# ------------------------ Extensions ------------------------
Expand Down

0 comments on commit 0bf8752

Please sign in to comment.