Skip to content

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

NameDescription
Intel VTuneCPU profiling with low-level information. Comes with tutorials.
Visual StudioIDE with good profiling support. Also allows to check threads loads with an extension.
OptixCPU & GPU profiler
Chrome TracingProfiler data viewer
NVidia NsightFrame Debugger & GPU profiler
RenderDocFrame Debugger with some GPU profiling data
Intel GPAFrame Debugger & GPU profiler

Books

NameDescription
C++ High PerformanceComes with a repository of examples

White Papers

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

Videos

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

Blogs

NameDescription
Fabian Giesen (ryg) websiteA great blog from a great engineer talking about CPU and GPU architectures
Blog at the bottom of the seaAlan Wolfe's graphic programming blogs with many articles on performance side
IT HareVarious and always high-quality articles for programmers
Simon SchreibtVarious articles on graphics programming performance tricks for various effects in AAA games
Joel on softwareVarious articles with many on performance and best practices by StackOverflow founder

Articles

NameDescription
Profiling processor cache missesAn article Ahmed Mahdy about intel VTune

Slides

NameDescription
Pitfall Of OOP - RevisitedA conference for TGC 2017 by Tony Albrecht on performances

Other

NameDescription
AwesomePerfCppA compilation of greats links on performance optimisation

About

Examples and tutorials for code performance improvements in C++

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages