Skip to content

Instantly share code, notes, and snippets.

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);
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 / 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 / k-mean on histogram.c
Last active September 26, 2016 06:05
k-mean for layer
gsl_rng_env_setup();
gsl_rng* rng = gsl_rng_alloc(gsl_rng_default);
sqlite3* db = 0;
int h[0x10000];
int kc[0x100];
float kmean[0x100];
uint16_t tbl[0x10000];
int i;
for (i = 0; i < 0x10000; i++)
tbl[i] = i;
#!/usr/bin/env ruby
meta = File.new "ILSVRC2010_test_ground_truth.txt"
ids = Array.new
i = 0
meta.each_line do |line|
ids << line.to_i
print ids[i].to_s + " test/ILSVRC2010_test_00" + ("%06d" % [i + 1]) + ".JPEG\n"
#!/usr/bin/env ruby
meta = File.new "meta.txt"
synsets = Hash.new
meta.each_line do |line|
dicts = line.split(" ")
synsets[dicts[1].to_s] = dicts[0].to_i;
end
#!/usr/bin/env ruby
exit unless ARGV.length == 1
files = Dir.glob(ARGV[0] + '/*.txt')
files.each do |file|
name = nil;
File.new(file).each_line do |line|
next if line[0] == '#'
@liuliu
liuliu / gist:5369041
Created April 12, 2013 03:15
ccv output on CMU
addams-family.png 81 505 45 45 7.843119
addams-family.png 328 174 50 50 12.569483
addams-family.png 736 552 49 49 8.898903
addams-family.png 659 387 46 46 6.503688
addams-family.png 423 144 55 55 0.090923
addams-family.png 711 87 53 53 6.657643
addams-family.png 138 405 51 51 5.100987
aeon1a.png 161 86 142 142 -0.815429
aerosmith-double.png 272 110 39 39 6.868231
aerosmith-double.png 103 16 42 42 5.516684