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
static void taskyield(task_t* const task) | |
{ | |
addtask(task->schd, task); | |
swapcontext(&task->schd->callee, &task->schd->caller); | |
} | |
static void taskresume(task_t* const task) | |
{ | |
ucontext_t old_context = task->schd->caller; | |
swapcontext(&task->schd->caller, &task->context); |
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
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); | |
} |
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
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; |
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
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); |
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 <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]; |
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 <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; | |
} |
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
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 |
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 <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]; | |
} |
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
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)) | |
{ |
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
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; |