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
#[cfg(all(target_arch = "x86_64", target_feature = "avx2"))] | |
unsafe fn hammcmp_256bit_avx2(mut a: &[u8], mut b: &[u8]) -> u32 { | |
use std::arch::x86_64::{*}; | |
let mut dist = 0; | |
while a.len() >= 32 { | |
let av = _mm256_loadu_si256(a.as_ptr() as *const _); | |
let bv = _mm256_loadu_si256(b.as_ptr() as *const _); | |
let axorb = _mm256_xor_si256(av, bv); | |
dist += _popcnt64(_mm256_extract_epi64(axorb, 0)); | |
dist += _popcnt64(_mm256_extract_epi64(axorb, 1)); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
$ (for C in 1.0 2.0 2.5 3.0 3.5 4.0; do echo "/cfg $C"; echo "/reset"; echo "How do I become famous?"; done) | ./target/release/chat --mirostat --cfg-scale 2.0 --system-prompt "act as an expert chef" | |
Using ChatML prompting format. | |
mpt_model_load: loading model from 'minmpt.cpp/models/ggml-mpt-7b-chat-q5_1.bin' - please wait ... | |
mpt_model_load: ggml ctx size = 5397.09 MB | |
mpt_model_load: ........................ done | |
mpt_model_load: model size = 5397.02 MB / num tensors = 194 | |
mpt_kvcache: memory_size = 1024.00 MB, n_mem = 65536 | |
CFG Mode on! | |
mpt_kvcache: memory_size = 1024.00 MB, n_mem = 65536 | |
cfg_scale=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
// make mcs; ./mcs file | |
// writes <sample size> as uint32 to mincore.bin followed by 1 mincore() per second for 60 seconds | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <errno.h> | |
#include <sys/types.h> | |
#include <sys/mman.h> | |
#include <sys/stat.h> | |
#include <stdint.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 <sys/mman.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
size_t memtotal() { | |
char buf[200]; | |
size_t ret; | |
FILE* meminfo = fopen("/proc/meminfo", "r"); | |
if (!meminfo) { |
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
// how to create a process pipeline in C, or: | |
// how does the shell execute something like this: | |
//// $ awk '{print $3}' < /proc/mounts | sort | uniq -c | |
#define _GNU_SOURCE // needed for pipe2 | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/wait.h> | |
#include <stdio.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
In [1]: from pathlib import Path | |
In [2]: from codecs import encode | |
In [3]: words = set(Path('/usr/share/dict/words').read_text().splitlines()) | |
In [4]: rot13 = set(encode(w, 'rot13') for w in words) | |
In [5]: [(w, encode(w, 'rot13')) for w in (words & rot13) if len(w) >= 3] | |
Out[5]: |
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
# 'make' doesn't need a makefile to compile basic C programs | |
$ make shr && ./shr | grep 'Vm\|\[\|Rss' | |
[P] Parent, pre munmap | |
VmPeak: 23708 kB | |
VmSize: 23708 kB | |
VmLck: 0 kB | |
VmPin: 0 kB | |
VmHWM: 20656 kB | |
VmRSS: 20656 kB | |
RssAnon: 88 kB |
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 <efi.h> | |
#include <efilib.h> | |
#define EFI_TRY(X) \ | |
status = X; \ | |
if (EFI_ERROR(status)) { \ | |
Print(L"Error on line %d (%s): %r", __LINE__, L ## #X, status); \ | |
goto cleanup; \ | |
} |
NewerOlder