Skip to content

Instantly share code, notes, and snippets.

@foxhoundsk
foxhoundsk / Matrix.md
Created May 27, 2018 21:03 — forked from nadavrot/Matrix.md
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of

@foxhoundsk
foxhoundsk / bpf_kern.c
Created January 17, 2021 11:35
syscall overhead measurement
#include <bpf.h>
#include <bpf_helpers.h>
#include <bpf_endian.h>
#include <stddef.h>
#include <string.h>
#include <asm/ptrace.h>
struct map {
__u64 ts;
};
1177591 | | | | | | | | | Return 0x00007fda66cfd592 /lib/x86_64-linux-gnu/libc.so.6:epoll_wait+0x000000000022 returns: 0x1
1170917 | | | | | | | Call 0x0000559d0037e437 /home/dces4212/project/nginx-1.18.0/objs/nginx:ngx_worker_process_init+0x0000000000da -> 0x0000559d00355d30 /home/dces4212/project/nginx-1.18.0/objs/nginx:.plt.sec+0x000000000420(0x7ffc91907550, 0x1, ...)
1170946 | | | | | | | Return 0x00007fda66c21c71 /lib/x86_64-linux-gnu/libc.so.6:sigemptyset+0x000000000031 returns: 0
1177606 | | | | | | | | | Call 0x0000559d003805f6 /home/dces4212/project/nginx-1.18.0/objs/nginx:ngx_epoll_init+0x0000000003d7 -> 0x0000559d00355be0 /home/dces4212/project/nginx-1.18.0/objs/nginx:.plt.sec+0x0000000002d0(0x9, 0x7ffc919073c4, ...)
1177616 | | | | | | | | | Return 0x00007fda67c803df /lib/x86_64-linux-gnu/libpthread.so.0:close+0x00000000001f returns: 0
1170951 | | | | | | | Call 0x0000559d0037e449 /home/dces4212/project/nginx-1.18.0/objs/nginx:ngx_worker_process_init+0x0000000000ec -> 0x0000559d0
$ sudo tlp-stat --psup
--- TLP 1.5.0 --------------------------------------------
+++ Power supply diagnostic
/sys/class/power_supply/AC0/type: Mains
/sys/class/power_supply/AC0/usb_type: (not available)
/sys/class/power_supply/AC0/online: 1
/sys/class/power_supply/AC0/voltage_max: (not available)
/sys/class/power_supply/AC0/voltage_min: (not available)
/sys/class/power_supply/AC0/voltage_now: (not available)
@foxhoundsk
foxhoundsk / mq_bench.c
Last active September 16, 2022 18:26
Benchmarking POSIX message queue
#define _GNU_SOURCE
#include <fcntl.h> /* For O_* constants */
#include <sys/stat.h> /* For mode constants */
#include <mqueue.h>
#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
@foxhoundsk
foxhoundsk / mq_lat.c
Created September 28, 2022 06:31
POSIX message queue latency benchmarking
#define _GNU_SOURCE
#include <fcntl.h> /* For O_* constants */
#include <sys/stat.h> /* For mode constants */
#include <mqueue.h>
#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
@foxhoundsk
foxhoundsk / mq_bench_app.c
Last active September 28, 2022 06:38
NASA cFS POSIX message queue latency benchmarking
#include <time.h>
#include <signal.h>
#include "sample1_app.h"
#include "sample1_app_events.h"
#include "sample1_app_msgids.h"
#include "sample1_app_perfids.h"
#include "sample1_app_version.h"
#include "sample1_data.h"
#include "app_lib.h"