Skip to content

Instantly share code, notes, and snippets.

static void _task_entry_point(uint32_t part0, uint32_t part1)
{
union ptr_splitter p;
p.part[0] = part0;
p.part[1] = part1;
task_t *task = (task_t*)p.ptr;
task->fn(task);
task->done = 1;
swapcontext(&task->schd->callee, &task->schd->caller);
}
static void deltask(schd_t* const schd, task_t* const t)
{
if (t->prev)
t->prev->next = t->next;
else
schd->head = t->next;
if (t->next)
t->next->prev = t->prev;
else
schd->tail = t->prev;
union ptr_splitter {
void *ptr;
uint32_t part[2];
};
static const int default_stack_size = 65536;
typedef struct schd_s schd_t;
typedef struct task_s task_t;
typedef void (*task_fn_t)(task_t *task);
@liuliu
liuliu / task.c
Last active May 20, 2022 07:02
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
#include <pthread.h>
#include "nnc/gpu/ccv_nnc_compat.h"
union ptr_splitter {
void *ptr;
uint32_t part[2];
@liuliu
liuliu / bsi.c
Last active December 11, 2016 04:23
#include <stdio.h>
#include <string.h>
static inline int _ccv_nnc_try_sort_and_insert(int* md, const int ins, const int c)
{
if (!c)
{
md[0] = ins;
return 1;
}
@liuliu
liuliu / Titan setup.txt
Last active August 29, 2015 14:08
4 GPU Titan Steup
My 4-GPU Titan / Titan Black Setup is like this:
PSU: www.newegg.com/Product/Product.aspx?Item=N82E16817182251
Motherboard: http://www.newegg.com/Product/Product.aspx?Item=N82E16813132262 (You have to switch the PCI-e port to at x8 speed and change boot parameter to include "pci=nomsi irqpoll" to get stable performance).
CPU: http://www.newegg.com/Product/Product.aspx?Item=N82E16819117402
Memory: http://www.newegg.com/Product/Product.aspx?Item=N82E16820231793
@liuliu
liuliu / cmov.c
Created September 18, 2014 04:38
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <zlib.h>
#include <assert.h>
static size_t get_atom_size(uint8_t* atom)
{
return (atom[0] << 24) | (atom[1] << 16) | (atom[2] << 8) | atom[3];
}
static void ccv_convnet_read_extra(ccv_convnet_t* convnet, const char* filename)
{
sqlite3* db = 0;
if (SQLITE_OK == sqlite3_open(filename, &db))
{
sqlite3_stmt* layer_quant_stmt = 0;
const char layer_quant_qs[] =
"SELECT layer, quant FROM layer_quant;";
if (SQLITE_OK == sqlite3_prepare_v2(db, layer_quant_qs, sizeof(layer_quant_qs), &layer_quant_stmt, 0))
{
sqlite3* db = 0;
assert(SQLITE_OK == sqlite3_open(argv[2], &db));
const char create_table_qs[] =
"CREATE TABLE IF NOT EXISTS layer_quant "
"(layer INTEGER PRIMARY KEY ASC, quant BLOB);";
assert(SQLITE_OK == sqlite3_exec(db, create_table_qs, 0, 0, 0));
const char data_insert_qs[] =
"REPLACE INTO layer_quant "
"(layer, quant) VALUES ($layer, $quant);";
sqlite3_stmt* data_insert_stmt = 0;
int f;
for (f = 10; f < 13; f++)
{
int i, j, k;
ccv_convnet_layer_t *layer = convnet->layers + f;
char filename[256];
float kmean[256];
sprintf(filename, "lut-layer-%d.txt", f);
FILE *r = fopen(filename, "r");
for (i = 0; i < 0x100; i++)