Skip to content

Instantly share code, notes, and snippets.

View ugovaretto's full-sized avatar

Ugo Varetto ugovaretto

View GitHub Profile
@ugovaretto
ugovaretto / benchmark
Last active August 29, 2015 14:27 — forked from spion/a-warning.md
C++ versus V8 versus luajit versus C benchmark - (hash) tables
spion@missperfect:~/Projects/testhash$ gcc -O3 test.c -o testc
spion@missperfect:~/Projects/testhash$ time ./testc
The 1000000
a 2000000
at 1000000
brown 1000000
dog 1000000
era 1000000
fox 1000000
jumped 1000000
@ugovaretto
ugovaretto / aligned_allocator.cpp
Created February 17, 2017 02:07 — forked from donny-dont/aligned_allocator.cpp
An aligned allocator for placing SIMD types in std::vector
#ifdef _WIN32
#include <malloc.h>
#endif
#include <cstdint>
#include <vector>
#include <iostream>
/**
* Allocator for aligned data.
@ugovaretto
ugovaretto / recvRawEth.c
Created September 9, 2018 14:21 — forked from austinmarton/recvRawEth.c
Receive raw Ethernet frames in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/ip.h>
@ugovaretto
ugovaretto / sendRawEth.c
Created September 9, 2018 14:21 — forked from austinmarton/sendRawEth.c
Send a raw Ethernet frame in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
@ugovaretto
ugovaretto / opencl-error-codes.txt
Created April 19, 2020 09:37 — forked from bmount/opencl-error-codes.txt
OpenCL Error Codes
CL_SUCCESS 0
CL_DEVICE_NOT_FOUND -1
CL_DEVICE_NOT_AVAILABLE -2
CL_COMPILER_NOT_AVAILABLE -3
CL_MEM_OBJECT_ALLOCATION_FAILURE -4
CL_OUT_OF_RESOURCES -5
CL_OUT_OF_HOST_MEMORY -6
CL_PROFILING_INFO_NOT_AVAILABLE -7
CL_MEM_COPY_OVERLAP -8
CL_IMAGE_FORMAT_MISMATCH -9
let offset = 20000;
let chunk_size = 10000;
// File handle:
let mut handle = BufReader::new(File::open("data.bin").await?);
// Set cursor to needed chunk:
let mut chunk_stream = handle
.bytes()
.skip(offset)
@ugovaretto
ugovaretto / parallel_op_vec.rs
Created April 9, 2022 02:19 — forked from sitag/parallel_op_vec.rs
[rust] operating on a vector in parallel with unsafe rust
#![feature(unique)]
use std::thread::spawn;
// operating on a vector in parallel
fn main() {
let mut data:Vec<u32> = vec![1u32, 2, 3];
println!("{:?}", data);
let head = data.as_mut_ptr();
let mut guards = (0..3).map(|i|
@ugovaretto
ugovaretto / work_queue.rs
Created April 19, 2022 08:20 — forked from NoraCodes/work_queue.rs
An example of a parallel work scheduling system using only the Rust standard library
// Here is an extremely simple version of work scheduling for multiple
// processors.
//
// The Problem:
// We have a lot of numbers that need to be math'ed. Doing this on one
// CPU core is slow. We have 4 CPU cores. We would thus like to use those
// cores to do math, because it will be a little less slow (ideally
// 4 times faster actually).
//
// The Solution:
@ugovaretto
ugovaretto / README.md
Created April 24, 2022 02:50 — forked from PurpleBooth/README.md
A github workflow pipeline for rust that does test, build and deploy windows, linux and mac, creates releases, and does SemVer Versioning, and releases to a homebrew tap

Features

  • Automatically bump SemVer
  • Update a personal homebrew tap
  • Keep that pesky version in the Cargo.toml up to date
  • (From dependabot) Get new versions out as soon as possible

Assumptions

  • You don't want a changelog