// File: /workspace/github_cpp_makefile_star2_O1/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
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpl $0x0, 0xb4(%rdi)
jle 0x4321
movl $0x1, %r14d
leaq 0x3e68(%rip), %r15      # 0x803c
leaq 0x20(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0x3f48(%rip), %rbp      # 0x812d
xorl %edi, %edi
callq 0x7630
movq %rbx, %rdi
callq 0x3f04
movaps %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movl $0x2, %esi
callq 0x407e
movaps %xmm0, 0x40(%rsp)
movss %xmm0, 0xc(%rsp)
xorl %edi, %edi
callq 0x7647
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]
xorps %xmm3, %xmm3
cvtss2sd %xmm2, %xmm3
xorps %xmm2, %xmm2
cvtss2sd %xmm5, %xmm2
cvtss2sd %xmm1, %xmm1
xorps %xmm5, %xmm5
cvtss2sd %xmm4, %xmm5
xorps %xmm4, %xmm4
cvtss2sd %xmm0, %xmm4
movq %r15, %rdi
movl %r14d, %esi
movaps %xmm5, %xmm0
movb $0x5, %al
callq 0x3060
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x4281
movss 0xc(%rsp), %xmm0
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x428c
movq %r12, %rdi
movq %r13, %rdx
callq 0x4fbc
movslq 0xb8(%rbx), %rax
testq %rax, %rax
setle %cl
cmpq %rax, %r14
setl %dl
orb %cl, %dl
jne 0x4302
movq 0x20(%rsp), %rcx
movl %r14d, %edx
subl %eax, %edx
movslq %edx, %rdx
xorps %xmm1, %xmm1
addss (%rcx,%rdx,4), %xmm1
incq %rdx
cmpq %r14, %rdx
jl 0x42b3
movss 0xc(%rsp), %xmm2
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss %xmm0, %xmm1
xorl %eax, %eax
ucomiss %xmm1, %xmm2
jbe 0x42fd
movq %rbp, %rdi
movss %xmm1, 0x10(%rsp)
movss %xmm2, 0x40(%rsp)
callq 0x32e0
movss 0x40(%rsp), %xmm2
movss 0x10(%rsp), %xmm1
movl $0x2, %eax
ucomiss %xmm1, %xmm2
ja 0x4304
xorl %eax, %eax
testl %eax, %eax
jne 0x432b
leaq 0x1(%r14), %rax
movslq 0xb4(%rbx), %rcx
cmpq %rcx, %r14
movq %rax, %r14
jl 0x41e5
jmp 0x432e
movss 0x3d0b(%rip), %xmm0     # 0x8034
jmp 0x4335
movq %r14, %rax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x10(%rsp)
xorl %edi, %edi
callq 0x7680
mulss 0x3cee(%rip), %xmm0     # 0x8038
divss 0x10(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3d2f(%rip), %rdi      # 0x808a
movb $0x1, %al
callq 0x3060
movl $0x1, %edi
callq 0x7630
movq %rbx, %rdi
movl $0x3, %esi
callq 0x407e
movaps %xmm0, 0x10(%rsp)
movl $0x1, %edi
callq 0x7647
movaps 0x10(%rsp), %xmm2
movaps %xmm2, %xmm1
shufps $0x55, %xmm2, %xmm1     # xmm1 = xmm1[1,1],xmm2[1,1]
cvtss2sd %xmm1, %xmm1
xorps %xmm3, %xmm3
cvtss2sd %xmm2, %xmm3
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
leaq 0x3cfd(%rip), %rdi      # 0x80aa
movaps %xmm3, %xmm0
movb $0x3, %al
callq 0x3060
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x43ce
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3200
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x43e7
jmp 0x43e7
jmp 0x43e7
jmp 0x43e7
jmp 0x43e7
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4401
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x3360
nop