// File: /workspace/github_cpp_makefile_star2_O2/yuang-chen[P]paraGCN/src/gcn.cpp
// Function: GCN::run()
void GCN::run() {
     int epoch = 1;
     float total_time = 0.0;
     vector<float> loss_history;

     for(; epoch <= params.epochs; epoch++) {
        float train_loss, train_acc, val_loss, val_acc;
        timer_start(TMR_TRAIN);
        tie(train_loss, train_acc) = train_epoch();
        tie(val_loss, val_acc) = eval(2);
        printf("epoch=%d train_loss=%.5f train_acc=%.5f val_loss=%.5f val_acc=%.5f time=%.5f\n",
            epoch, train_loss, train_acc, val_loss, val_acc, timer_stop(TMR_TRAIN));
        loss_history.emplace_back(val_loss);
        if(params.early_stopping > 0 && epoch >= params.early_stopping) {
            float recent_loss = 0.0;
            for(int i = epoch - params.early_stopping; i < epoch; i++) {
                recent_loss += loss_history[i];
            }
            if(val_loss > recent_loss / params.early_stopping) {
                printf("early stopping...\n");
                break;
            }
        }
    }
    PRINT_TIMER_AVERAGE(TMR_TRAIN, epoch);


    float test_loss, test_acc;
    timer_start(TMR_TEST);
    tie(test_loss, test_acc) = eval(3);
    printf("test_loss=%.5f test_acc=%.5f time=%.5f\n", test_loss, test_acc, timer_stop(TMR_TEST));
 }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
pushq $0x1
popq %r14
pushq $0x2
popq %rbp
leaq 0x4172(%rip), %r12      # 0x8038
leaq 0xc(%rsp), %r13
movslq 0xb4(%rbx), %rax
cmpq %rax, %r14
jg 0x3faf
xorl %edi, %edi
callq 0x6f20
movq %rbx, %rdi
callq 0x3d60
movaps %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3e22
movaps %xmm0, 0x40(%rsp)
movss %xmm0, 0xc(%rsp)
xorl %edi, %edi
callq 0x6f37
movaps 0x10(%rsp), %xmm4
movaps %xmm4, %xmm1
shufps $0x55, %xmm4, %xmm1     # xmm1 = xmm1[1,1],xmm4[1,1]
movaps 0x40(%rsp), %xmm5
movaps %xmm5, %xmm2
shufps $0x55, %xmm5, %xmm2     # xmm2 = xmm2[1,1],xmm5[1,1]
cvtss2sd %xmm2, %xmm3
cvtss2sd %xmm5, %xmm2
cvtss2sd %xmm1, %xmm1
cvtss2sd %xmm4, %xmm5
cvtss2sd %xmm0, %xmm4
movq %r12, %rdi
movl %r14d, %esi
movaps %xmm5, %xmm0
movb $0x5, %al
callq 0x3050
movq %r15, %rdi
movq %r13, %rsi
callq 0x431a
movslq 0xb8(%rbx), %rax
testq %rax, %rax
setle %cl
cmpq %rax, %r14
setl %dl
orb %cl, %dl
jne 0x3f9b
movq 0x20(%rsp), %rcx
movl %r14d, %edx
subl %eax, %edx
movslq %edx, %rdx
xorps %xmm0, %xmm0
cmpq %r14, %rdx
jge 0x3f88
addss (%rcx,%rdx,4), %xmm0
incq %rdx
jmp 0x3f79
cvtsi2ss %eax, %xmm1
movss 0xc(%rsp), %xmm2
divss %xmm1, %xmm0
ucomiss %xmm0, %xmm2
ja 0x3fa3
incq %r14
jmp 0x3ecb
leaq 0x417f(%rip), %rdi      # 0x8129
callq 0x32e0
xorl %edi, %edi
callq 0x6f70
cvtsi2ss %r14d, %xmm1
mulss 0x4071(%rip), %xmm0     # 0x8034
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x40b4(%rip), %rdi      # 0x8086
movb $0x1, %al
callq 0x3050
pushq $0x1
popq %rdi
callq 0x6f20
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x3e22
movaps %xmm0, 0x10(%rsp)
pushq $0x1
popq %rdi
callq 0x6f37
movaps 0x10(%rsp), %xmm2
movaps %xmm2, %xmm1
shufps $0x55, %xmm2, %xmm1     # xmm1 = xmm1[1,1],xmm2[1,1]
cvtss2sd %xmm1, %xmm1
cvtss2sd %xmm2, %xmm3
cvtss2sd %xmm0, %xmm2
leaq 0x408e(%rip), %rdi      # 0x80a6
movaps %xmm3, %xmm0
movb $0x3, %al
callq 0x3050
leaq 0x20(%rsp), %rdi
callq 0x4e08
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4045
jmp 0x4045
jmp 0x4045
jmp 0x4045
jmp 0x4045
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4e08
movq %rbx, %rdi
callq 0x3360