This file contains hidden or 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
// Compile on linux with `gcc gol_simd.c -O3 -march=native` with a modern intel CPU | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
#include <time.h> | |
#include <string.h> | |
#include <x86intrin.h> | |
#include <wchar.h> | |
#include <locale.h> |
This file contains hidden or 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
canvas { | |
image-rendering: pixelated; | |
image-rendering: crisp-edges; | |
image-rendering: -moz-crisp-edges; | |
image-rendering: -webkit-optimize-contrast; | |
-ms-interpolation-mode: nearest-neighbor; | |
} |
This file contains hidden or 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
; nasm -f elf printf-test.asm && gcc -m32 -o printf-test printf-test.o | |
; Variables | |
; multiplier a --> edx (doesn't work; using [mult]) | |
; adder b --> ebx | |
; term x --> eax | |
; count i --> ecx | |
; x + 1 --> esi | |
; mask --> 255 | |
; masj --> 254 = mask - 1 | |
section .data |
This file contains hidden or 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
// gcc bfparallel.c -std=c17 -O3 -march=native -fno-stack-protector -Wall -Wextra -Werror -pedantic -o bfparallel | |
#include <stdio.h> | |
#include <pthread.h> | |
#include <signal.h> | |
#include <stdint.h> | |
#ifndef THREAD_COUNT | |
#define THREAD_COUNT 16 | |
#endif | |
#ifndef modulus | |
#define modulus 0x7ffffff |
This file contains hidden or 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
Math.umul = (a, b) => { | |
const aLow = a & 65535; | |
return (b * (a - aLow) >>> 0) + (b * aLow) >>> 0; | |
}; | |
Math.umulhl = (a, b) => Uint32Array.of(a * b * 2.3283064365386963e-10, Math.umul(a, b)); | |
Math.umul64 = (aHi, aLo, bHi, bLo) => { | |
const a0 = aHi & 65535, a1 = aHi - a0, a2 = aLo & 65535, a3 = aLo - a2, | |
lohi = bLo * a0 + (bLo * a1 >>> 0) >>> 0, | |
hilo = bHi * a2 + (bHi * a3 >>> 0) >>> 0, | |
carry = aLo * bLo * 2.3283064365386963e-10 >>> 0; |
This file contains hidden or 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
{ | |
"name":"Charly", | |
"money":16, | |
"Capital":{"x":6,"y":5}, | |
"Cities":[ | |
{"x":4,"y":5}, {"x":6,"y":7} | |
], | |
"Colonies":[ | |
{"x":5,"y":4}, {"x":7,"y":6} | |
], |