Skip to content

Instantly share code, notes, and snippets.

Nicolas Guillemot nlguillemot

View GitHub Profile
@nlguillemot
nlguillemot / main.cpp
Created Apr 28, 2017
stable opengl timestamps with D3D12
View main.cpp
#ifdef _WIN32
#include <d3d12.h>
#include <dxgi1_5.h>
#pragma comment(lib, "d3d12.lib")
#pragma comment(lib, "dxgi.lib")
#endif
#ifdef _WIN32
void SetStablePowerState()
@nlguillemot
nlguillemot / tasks.md
Last active Feb 17, 2018
Musings on task parallelism
View tasks.md

In order to effectively use a multi-core CPU, a decomposition of code into tasks must be made. By decomposing code into tasks, the tasks can be distributed among CPU cores by a scheduler. Tasks can have dependencies on other tasks, meaning that the tasks execute in a partial order. This partial order can be represented as a graph, where each task has predecessors and successors. A task can only execute when all its predecessors have completed.

To implement this, we can explicitly create a graph of tasks, with edges between tasks to identify predecessor/successor relationships. The problem with a general task graph system is that it's not productive to work with. Maybe it's okay for some purposes to have a GUI interface to build a task graph, but that's too tedious for everyday code. Imagine if you had to explicitly create nodes and edges when implementing a single-threaded function call graph, it would be so tedious!

View main.cpp
#include <Windows.h>
#include <GL/gl.h>
#pragma comment(lib, "OpenGL32.lib")
LRESULT CALLBACK MyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CLOSE:
@nlguillemot
nlguillemot / p4vsissues.md
Last active Aug 29, 2015
P4VS problems I've encountered
View p4vsissues.md

From memory...

  • Periodically freezes Visual Studio for a long period of time while refreshing status.
    • Workaround: Set the refresh period to some obscenely huge number (the status of your files is then never refreshed)
  • Tends to give P4 error pop-ups when opening files outside of your project (eg: stdlib headers, files from other projects...)
  • Deleting files from project (while simultaneously marking for delete) gives an error saying the file doesn't exist (but also deletes it. double delete?)
  • Deleting N files from a project sequentially gives N pop-ups asking if you also want to mark for delete
@nlguillemot
nlguillemot / main.cpp
Last active Aug 29, 2015
value initialized member struct
View main.cpp
#include <iostream>
using namespace std;
struct X
{
int a,b,c;
};
struct Y
@nlguillemot
nlguillemot / output from webcompiler.cloudapp.net
Last active Aug 29, 2015
value initializing unions inside a struct
View output from webcompiler.cloudapp.net
Compiled with /EHsc /nologo /W4
main.cpp
Compilation successful!
Total compilation time: 109ms
0 0 0 0 0 0 0 0 0 0
50790056 50790132 50790220 49536592 -1801320171 -2 49555713 49555747 49683692 6
@nlguillemot
nlguillemot / to_tstring.hpp
Created Jun 2, 2015
to_string based on TCHAR
View to_tstring.hpp
namespace detail
{
template<class T>
std::string to_tstring(CHAR, const T& x) { return std::to_string(x); }
template<class T>
std::wstring to_tstring(WCHAR, const T& x) { return std::to_wstring(x); }
}
template<class T>
auto to_tstring(const T& x)
@nlguillemot
nlguillemot / !What is this?
Last active Aug 29, 2015
Transposing a CSV file (with '|' instead of ',')
View !What is this?
People these days love to throw GPUs at every problem they can.
Sometimes it works well, other times it's a waste of power.
This program was written to show that you don't need a big high end GPU to parse a CSV file quickly,
in reponse to https://github.com/antonmks/nvParse
Can probably be optimized more. Gotta try running it on a SSD sometime.
Either way, much more competitive than the strawman CPU implementations on the above project page.
@nlguillemot
nlguillemot / main.cpp
Created Mar 28, 2015
Polling for changes in a directory
View main.cpp
#include <Windows.h>
int main()
{
// Create a file change notification object that can be used to check for file changes.
HANDLE hNotif = FindFirstChangeNotification("C:\\Path\\To\\My\\Directory", TRUE, FILE_NOTIFY_CHANGE_LAST_WRITE);
while (1)
{
// Wait until a file change notification happens.
View superbasicgl.cpp
#include <windows.h>
#include <GL/gl.h>
#include <cmath>
int lineWidth = 1;
LRESULT CALLBACK MyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CLOSE)
You can’t perform that action at this time.