Mercurial > hg > Game > Cerium
changeset 1100:dcb025b46cae draft
fix.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 31 Dec 2010 16:24:01 +0900 |
parents | 3b3b535baa51 |
children | 1da96a535437 |
files | example/ResizeWritebuf/Container.h example/ResizeWritebuf/main.cc example/ResizeWritebuf/ppe/Resize.cc |
diffstat | 3 files changed, 26 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/ResizeWritebuf/Container.h Fri Dec 31 16:24:01 2010 +0900 @@ -0,0 +1,6 @@ + +typedef struct Container { + int length; + + int data; +} Container, *ContainerPtr;
--- a/example/ResizeWritebuf/main.cc Fri Dec 31 15:58:32 2010 +0900 +++ b/example/ResizeWritebuf/main.cc Fri Dec 31 16:24:01 2010 +0900 @@ -2,6 +2,7 @@ #include <stdlib.h> #include <string.h> #include "TaskManager.h" +#include "Container.h" #include "Func.h" extern void task_init(void); @@ -134,26 +135,29 @@ } -void +static void checkData(SchedTask *s, void *data, void *arg1) { - int *idata = (int*)data; - for (int i = 0;i < data_length;i++) { - int p_data = idata[i]; - printf("data[%d] = %d\n", i, p_data); + ContainerPtr obj = (ContainerPtr)data; + int data_length = obj->length; + + for(int i =0;i <data_length;i++) { + int data = obj[i].data; + printf("data[%d] = %d\n", i, data); } + free(data); } -void +static void resize_init(TaskManager *manager) { - HTaskPtr resize_task = manager->create_task(Resize); - int *obj = (int*)manager->allocate(sizeof(int)*data_size); + HTaskPtr resize_task = manager->create_task(RESIZE); + ContainerPtr obj = (ContainerPtr)manager->allocate(sizeof(Container)*data_size); + obj->length = data_length; - resize_task->set_param(0, (memaddr)data_length); - resize_task->set_inData(0, obj, sizeof(int)*data_size); + resize_task->set_inData(0, obj, sizeof(Container)*data_size); resize_task->set_outData(0, obj, 0); resize_task->set_post(checkData, (void*)obj, NULL);
--- a/example/ResizeWritebuf/ppe/Resize.cc Fri Dec 31 15:58:32 2010 +0900 +++ b/example/ResizeWritebuf/ppe/Resize.cc Fri Dec 31 16:24:01 2010 +0900 @@ -1,5 +1,6 @@ #include <stdio.h> #include "SchedTask.h" +#include "../Container.h" #include "Resize.h" #include "Func.h" @@ -9,14 +10,15 @@ static int resize(SchedTask *smanager, void *rbuf, void *wbuf) { - int length = (int)smanager->get_param(0); - int *idata = (int*)smanager->get_output(rbuf, 0); + ContainerPtr icontainer = (ContainerPtr)smanager->get_input(rbuf, 0); + int length = icontainer->length; + ContainerPtr wcontainer = (ContainerPtr)smanager->get_output(wbuf, 0); - smanager->set_outputSize(0, sizeof(int)*length); + smanager->set_outputSize(0, sizeof(Container)*length); smanager->setup_outputData(); for (int i =0; i < length;i++) { - idata[i] = i; + wcontainer[i].data = i; } return 0;