Skip to content

Instantly share code, notes, and snippets.

Liu Liu liuliu

Block or report user

Report or block liuliu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:f65a6f5ae91e605247ece396de35dc90
create a new task to resume 0x288d010
start task 0x289d410
done task 0x288d010
back to task 0x289d410 to finish
View cuda-coroutine.c
static void taskcudaresume(cudaStream_t stream, cudaError_t status, void* userdata)
{
task_t* const task = (task_t*)userdata;
pthread_mutex_lock(&task->schd->mutex);
addtask(task->schd, task);
--task->schd->count.suspend;
pthread_cond_signal(&task->schd->cv);
pthread_mutex_unlock(&task->schd->mutex);
}
View test-coroutine.c
static void g(task_t* const task)
{
printf("start task %p\n", task);
taskyield(task);
printf("back to task %p to finish\n", task);
}
static void f(task_t* const task)
{
printf("create a new task to resume %p\n", task);
View task-yield.c
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);
View new-task.c
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);
}
View coroutine-main-run-loop.c
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;
View coroutine-basic-data.c
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);
View task.c
#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];
View bsi.c
#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 Aug 29, 2015
4 GPU Titan Steup
View Titan setup.txt
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
You can’t perform that action at this time.