This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdio.h> | |
#include <time.h> | |
#define COBJMACROS | |
#include <windows.h> | |
#include <d3d11_1.h> | |
#include <d3dcompiler.h> | |
////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#define COBJMACROS | |
#include <windows.h> | |
#include <d3d11_1.h> | |
#include <d3dcompiler.h> | |
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
#define TITLE "D3D11 Triangle C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package block_allocator | |
// Allocator based on Sebastian Aaltonen's Offset Allocator: | |
// https://github.com/sebbbi/OffsetAllocator/blob/main/offsetAllocator.cpp | |
import "core:fmt" | |
import "core:math/bits" | |
import "core:math/rand" | |
assert_allocator_layout_good :: proc(allocator: ^Block_Allocator) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define _WINSOCK_DEPRECATED_NO_WARNINGS | |
#define ENET_IMPLEMENTATION | |
#include "enet.h" | |
int main() | |
{ | |
if (enet_initialize() != 0) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const ArrayInfo = struct { | |
rank: usize, | |
child: type, | |
}; | |
fn arrayInfo(comptime artype: type) ArrayInfo { | |
var rank: usize = 0; | |
var currentType: type = artype; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const expect = @import("std").testing.expect; | |
/// The additive identity for this scalar type. | |
inline fn zero(comptime T: type) T { | |
return 0; | |
} | |
/// The multiplicative identity for this scalar type. | |
inline fn one(comptime T: type) T { | |
return 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assert = @import("std").debug.assert; | |
fn make_mask_3_f32(cond: [3]bool) [3]f32 { | |
var mask: [3]f32 = undefined; | |
const ar_cond: [3]bool = cond; | |
comptime var i = 0; | |
inline while (i < 3) : (i += 1) { | |
mask[i] = if (ar_cond[i]) 1.0 else 0.0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
// This program starts numProcs goroutines which each generate numSteps random | |
// numbers and prints the amount of time it takes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This program starts N goroutines which each generate numSteps random | |
// numbers and prints the amount of time it takes. | |
// | |
// See if you can you figure out why it doesn't parallelise properly. | |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
NewerOlder