// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0xb4(%rdi)
jle 0x42e6
movl $0x1, %r14d
leaq 0x3e69(%rip), %r15      # 0x8038
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %r13
xorl %edi, %edi
callq 0x76b4
movq %rbx, %rdi
callq 0x3f04
movaps %xmm0, 0x30(%rsp)
movq %rbx, %rdi
movl $0x2, %esi
callq 0x407a
movaps %xmm0, 0x40(%rsp)
movss %xmm0, 0xc(%rsp)
xorl %edi, %edi
callq 0x76cb
movaps 0x30(%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 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x4275
movss 0xc(%rsp), %xmm0
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x4280
movq %r12, %rdi
movq %r13, %rdx
callq 0x4f52
movslq 0xb8(%rbx), %rax
testq %rax, %rax
setle %cl
cmpq %rax, %r14
setl %dl
orb %cl, %dl
jne 0x42ca
movq 0x10(%rsp), %rcx
movl %r14d, %edx
subl %eax, %edx
movslq %edx, %rdx
xorps %xmm0, %xmm0
addss (%rcx,%rdx,4), %xmm0
incq %rdx
cmpq %r14, %rdx
jl 0x42a7
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movss 0xc(%rsp), %xmm2
divss %xmm1, %xmm0
ucomiss %xmm0, %xmm2
ja 0x42ee
leaq 0x1(%r14), %rax
movslq 0xb4(%rbx), %rcx
cmpq %rcx, %r14
movq %rax, %r14
jl 0x41d9
movl %eax, %r14d
jmp 0x42fa
movl $0x1, %r14d
jmp 0x42fa
leaq 0x3e34(%rip), %rdi      # 0x8129
callq 0x32e0
xorl %edi, %edi
callq 0x7704
xorps %xmm1, %xmm1
cvtsi2ss %r14d, %xmm1
mulss 0x3d23(%rip), %xmm0     # 0x8034
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3d66(%rip), %rdi      # 0x8086
movb $0x1, %al
callq 0x3060
movl $0x1, %edi
callq 0x76b4
movq %rbx, %rdi
movl $0x3, %esi
callq 0x407a
movaps %xmm0, 0x30(%rsp)
movl $0x1, %edi
callq 0x76cb
movaps 0x30(%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 0x3d34(%rip), %rdi      # 0x80a6
movaps %xmm3, %xmm0
movb $0x3, %al
callq 0x3060
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4393
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3200
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x43ab
jmp 0x43ab
jmp 0x43ab
jmp 0x43ab
jmp 0x43ab
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x43c5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x3360
nop