Mercurial > hg > Game > Cerium
view TaskManager/Test/Sum/main.cpp @ 9:964b3b27846d
*** empty log message ***
author | gongo |
---|---|
date | Wed, 06 Feb 2008 18:31:30 +0900 |
parents | b02b69ebb89a |
children | 7aa4c006e4be |
line wrap: on
line source
#include <stdio.h> #include <string.h> #include "TaskManager.h" #define MAX 1024 int data[MAX] __attribute__((aligned(16))); int buff[MAX] __attribute__((aligned(16))); int out[MAX] __attribute__((aligned(16))); typedef unsigned long long Uint64; typedef unsigned int Uint32; int main(void) { int i; int div = MAX/16; TaskManager *manager; HTaskPtr *task = new HTaskPtr[div]; HTaskPtr last; manager = new TaskManager(1); manager->init(); for (i = 0; i < MAX; i++) { data[i] = i; } memset(buff, 0, sizeof(int)*1024); memset(out, 0, sizeof(int)*1024); for (i = 0; i < div; i++) { task[i] = manager->create_task(4, sizeof(int)*16, (Uint32)&data[i*16], (Uint32)&buff[i*4], NULL); } last = manager->create_task(5, sizeof(int)*256, (Uint32)buff, (Uint32)&out[0], NULL); #if 0 for (i = 0; i < div-1; i++) { manager->set_task_depend(task[i], task[i+1]); } manager->set_task_depend(task[div-1], last); for (i = 0; i < div; i++) { manager->run_task(task[i]); } manager->run_task(last); #else for (i = 0; i < div; i++) { manager->set_task_depend(task[i], last); } for (i = 0; i < div; i++) { manager->run_task(task[i]); } manager->run_task(last); #endif manager->run(); printf("manager : %d\n", out[0]); out[0] = 0; for (i = 0; i < MAX; i++) { out[0] += i; } printf("for : %d\n", out[0]); return 0; }