2020/08/11

2020/08/11

# 先週

# 今週

  • 結膜炎です\(^o^)/
    • 視力低下を感じる
  • 学サポでB2,B3にJavaとPythonでデータ分析のやつを教える
    • 1日に4時間教えたりしてしんどい
  • シス管関連
    • スイッチのconfigを解析するやつ等々
  • そのた

# gearsの例題

  • localCode絡みの問題

    • revision 645だと動く
  • 従来のGearsはこういう書き方が多い

  • main.cbc

    • goto時の引数を省略する
    • metaになる -> stubで値を取り出しているので今までは問題ない
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
__code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
    // loopCounter->tree = createRedBlackTree(context);
    loopCounter->i = 0;
    taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
    struct Timer* timer = Gearef(context, Timer);
    goto code1();
}

__code code1(struct Timer* timer) {
    printf("cpus:\t\t%d\n", cpu_num);
    printf("gpus:\t\t%d\n", gpu_num);
    printf("length:\t\t%d\n", length);
    goto createTask1();
}

__code code2(struct TaskManager* taskManager) {
    goto taskManager->shutdown(exit_code);
}

__code code2_stub(struct Context* context) {
    goto code2(context, &Gearef(context, TaskManager)->taskManager->TaskManager);
}
  • SynchronizedQueue
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
__code putSynchronizedQueue(struct SynchronizedQueue* queue, union Data* data, __code next(...)) {
    Element* element = new Element();
    element->data = data;
    element->next = NULL;
    Element* last = queue->last;
    Element* nextElement = last->next;
    if (last != queue->last) {
        goto putSynchronizedQueue();
    }
    if (nextElement == NULL) {
        struct Atomic* atomic = queue->atomic;
        goto atomic->checkAndSet(&last->next, nextElement, element, next(...), putSynchronizedQueue);
    } else {
        struct Atomic* atomic = queue->atomic;
        goto atomic->checkAndSet(&queue->last, last, nextElement, putSynchronizedQueue, putSynchronizedQueue);
    }
}

__code takeSynchronizedQueue(struct SynchronizedQueue* queue, __code next(union Data* data, ...)) {
    struct Element* top = queue->top;
    struct Element* last = queue->last;
    struct Element* nextElement = top->next;
    if (top != queue->top) {
        goto takeSynchronizedQueue();
    }
    if (top == last) {
        if (nextElement != NULL) {
            struct Atomic* atomic = queue->atomic;
            goto atomic->checkAndSet(&queue->last, last, nextElement, takeSynchronizedQueue, takeSynchronizedQueue);
        }
    } else {
        struct Atomic* atomic = queue->atomic;
        goto atomic->checkAndSet(&queue->top, top, nextElement, takeSynchronizedQueue1, takeSynchronizedQueue);
    }
    goto takeSynchronizedQueue();
}

# 一応治せるが…

  • コンパイル時にwarningが出まくる
    • 型があってないと主張される…(コンパイラのバグ?)
    • boundedbufferは引数を埋めた所、errorは出なくなったがセグフォ
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c: In function 'initDataGears':
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c:21:10: warning: implicit declaration of function 'code1' [-Wimplicit-function-declaration]
   21 |     goto code1(context, timer);
      |          ^~~~~
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c: At top level:
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c:30:8: warning: conflicting types for 'code1'
   30 | __code code1(struct Context *context,struct Timer* timer) {
      |        ^~~~~
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c:21:10: note: previous implicit declaration of 'code1' was here
   21 |     goto code1(context, timer);
      |          ^~~~~
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c: In function 'code1':
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c:34:10: warning: implicit declaration of function 'createTask1'; did you mean 'createTask1_stub'? [-Wimplicit-function-declaration]
   34 |     goto createTask1(context, &GearImpl(context, TaskManager, taskManager));
      |          ^~~~~~~~~~~
      |          createTask1_stub
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c: At top level:
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c:53:8: warning: conflicting types for 'createTask1'
   53 | __code createTask1(struct Context *context,struct TaskManager* taskManager) {
      |        ^~~~~~~~~~~
/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/boundedBuffer/main.c:34:10: note: previous implicit declaration of 'createTask1' was here
   34 |     goto createTask1(context, &GearImpl(context, TaskManager, taskManager));
      |          ^~~~~~~~~~~

# 解決策

  • mata goto nextcodeGearName(...)みたいにするとgoto meta強制になる
    • それ以外はlocalCodeの挙動に準拠する
  • このあたりはどうせPerlで変換するので変換ルールフォーマットファイルを定義するのもいいかもしれない
  • metaに渡す情報は構造体で定義したい希ガスる
    • どうやるかはなやみどころ(あんま最近やってない…
1
2
3
goto meta(context, arg[type => C_exampleXtake2_single_linked_stack, 
                       InputData => struct exampleXtak2_sinle_linked_stack { },
                       ]);
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy