Mercurial > hg > Gears > Gears
view src/parallel_execution/examples/DPPMC/main.cbc @ 906:7dd8df7ceb69
fix
author | ikkun <ikkun@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Jan 2021 21:17:37 +0900 |
parents | b69b748e61d9 |
children | 90c0ea7811ea |
line wrap: on
line source
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include "../../../context.h" #interface "TaskManager.h" #interface "Phils.h" #interface "Fork.h" #interface "AtomicT_int.h" extern void addMemoryPhilsImpl(MCTaskManagerImpl *mcti, struct PhilsImpl* phils); int cpu_num = 1; int length = 102400; int split = 8; int* array_ptr; int gpu_num = 0; int CPU_ANY = -1; int CPU_CUDA = -1; __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { // loopCounter->tree = createRedBlackTree(context); loopCounter->i = 0; taskManager->taskManager = (union Data*)createMCTaskManagerImpl(context, cpu_num, gpu_num, 0); goto code1(); } __code code1(struct LoopCounter* loopCounter) { printf("cpus:\t\t%d\n", cpu_num); printf("gpus:\t\t%d\n", gpu_num); printf("length:\t\t%d\n", length); printf("length/task:\t%d\n", length/split); /* puts("queue"); */ /* print_queue(context->data[ActiveQueue]->queue.first); */ /* puts("tree"); */ /* print_tree(context->data[Tree]->tree.root); */ /* puts("result"); */ goto createTask1(); } __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { AtomicT_int* fork0 = createAtomicT_intImpl_int(context,-1); // model checking : fork0 AtomicT_int* fork1 = createAtomicT_intImpl_int(context,-1); // model checking : fork1 AtomicT_int* fork2 = createAtomicT_intImpl_int(context,-1); // model checking : fork2 AtomicT_int* fork3 = createAtomicT_intImpl_int(context,-1); // model checking : fork3 AtomicT_int* fork4 = createAtomicT_intImpl_int(context,-1); // model checking : fork4 struct MCTaskManagerImpl *mcti = (struct MCTaskManagerImpl *)taskManager->taskManager; Phils* phils0 = createPhilsImpl(context,0,fork0,fork1); // model checking : phils0 addMemoryPhilsImpl(mcti,(struct PhilsImpl*)phils0->phils); Phils* phils1 = createPhilsImpl(context,1,fork1,fork2); // model checking : phils1 addMemoryPhilsImpl(mcti,(struct PhilsImpl*)phils1->phils); Phils* phils2 = createPhilsImpl(context,2,fork2,fork3); // model checking : phils2 addMemoryPhilsImpl(mcti,(struct PhilsImpl*)phils2->phils); Phils* phils3 = createPhilsImpl(context,3,fork3,fork4); // model checking : phils3 addMemoryPhilsImpl(mcti,(struct PhilsImpl*)phils3->phils); Phils* phils4 = createPhilsImpl(context,4,fork4,fork0); // model checking : phils4 addMemoryPhilsImpl(mcti,(struct PhilsImpl*)phils4->phils); par goto phils0->thinking(exit_code); par goto phils1->thinking(exit_code); par goto phils2->thinking(exit_code); par goto phils3->thinking(exit_code); par goto phils4->thinking(exit_code); goto code2(); } __code code2(struct TaskManager* taskManager) { goto taskManager->shutdown(exit_code); } __code code2_stub(struct Context* contextt) { goto code2(contextt, &Gearef(contextt, TaskManager)->taskManager->TaskManager); } void init(int argc, char** argv) { for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-cpu") == 0) cpu_num = (int)atoi(argv[i+1]); else if (strcmp(argv[i], "-l") == 0) length = (int)atoi(argv[i+1]); else if (strcmp(argv[i], "-s") == 0) split = (int)atoi(argv[i+1]); else if (strcmp(argv[i], "-cuda") == 0) { gpu_num = 1; CPU_CUDA = 0; } } } int main(int argc, char** argv) { init(argc, argv); goto initDataGears(); }