Skip to content

Examples and tutorials for code performance improvements in C++

License

Notifications You must be signed in to change notification settings

learn-computer-graphics/code-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Optimization

Examples and tutorials for code performance improvements for CPU in C++. For GPGPU check learn-cuda repository.

🚩 Table of Contents

🧩 Show Classes

(🏗️ : Not started | 📝 : Started | 📑 : Needs proofreading | ✔️ : Written )

👩‍💻 Getting Started

Cloning with submodules

Open a command line and run :

git clone --recurse-submodules -j8 https://github.com/learn-computer-graphics/code-optimization.git

Prerequisites

You can read the classes listed in the table of contents, but if you want to follow along, you need to install CMake to build the project, and a C++ compiler which handles C++17.

Some projects are using external libraries such as OpenCV, details to install them are detailled below.

Linux

sudo apt-get install build-essential cmake libopencv-dev

Windows

To get the MSVC compiler, you need to install Visual Studio (and not VSCode), and select C++ development during installation. For additionnal dependencies it is recommanded that you use the official microsoft package manager vcpkg.

vcpkg install opencv

If you use vcpgk, you will need to give its path for the cmake build. Here is an exemple in command line :

cmake -DCMAKE_TOOLCHAIN_FILE=[your vcpkg root]/scripts/buildsystems/vcpkg.cmake

If you use the VSCode editor, you can change the path in .vscode/settings.json. Beware your installed lib triplets to match your vscode build settings (x86 or x64).

Build on desktop

You can handle the CMakeLists.txt in any way you like, here's some way to use it :

Option 1: CLI

Go to the folder of this project and run :

mkdir build
cd build
cmake ..
make

Option 2: Visual Studio (Windows only)

Open this folder with the CMake... option in file->open on Visual Studio, and run the project.

Option 3: VSCode

Use the CMakeTools plugin, build with f7 then run with f5 (But be careful to be on the right platform, there is a launch file for windows and for linux).

🕵️‍♂️ Profiling

You can use the Tracy profiler to check the performance of the code. Simply download and run its executable. When opened, click on connect.

Then if you run an executable from this project in admin, Tracy will be able to provide dissassembly information.

👨‍👩‍👦‍👦 Contributing

If you find errors in the code, or better way to explain or do things, feel free to open an issue !

📖 Sources

Tools

Name Description
Intel VTune CPU profiling with low-level information. Comes with tutorials.
Visual Studio IDE with good profiling support. Also allows to check threads loads with an extension.
Optix CPU & GPU profiler
Chrome Tracing Profiler data viewer
NVidia Nsight Frame Debugger & GPU profiler
RenderDoc Frame Debugger with some GPU profiling data
Intel GPA Frame Debugger & GPU profiler

Books

Name Description
C++ High Performance Comes with a repository of examples

White Papers

Name Description
Software Optimisation Resources A serie of in-deepth document by Agner Fog on low level CPU architectures and ways to optimise data usage for them.

Videos

Name Description
What's a creel - Modern x64 assembly A serie of video on Assembly Language. His channel has also a lot of ressources related to CPU performance.

Blogs

Name Description
Fabian Giesen (ryg) website A great blog from a great engineer talking about CPU and GPU architectures
Blog at the bottom of the sea Alan Wolfe's graphic programming blogs with many articles on performance side
IT Hare Various and always high-quality articles for programmers
Simon Schreibt Various articles on graphics programming performance tricks for various effects in AAA games
Joel on software Various articles with many on performance and best practices by StackOverflow founder

Articles

Name Description
Profiling processor cache misses An article Ahmed Mahdy about intel VTune

Slides

Name Description
Pitfall Of OOP - Revisited A conference for TGC 2017 by Tony Albrecht on performances

Other

Name Description
AwesomePerfCpp A compilation of greats links on performance optimisation

About

Examples and tutorials for code performance improvements in C++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published