// File: /workspace/github_cpp_makefile_star2_O3/poseidon1214[P]logistic-regression-ftrl-mpi/src/ftrl.h
// Function: FTRL::update()
void update(){// only for master node
            //reduce global gradient
            for(int j = 0; j < data->glo_fea_dim; j++){//store local gradient to glo_g;
                glo_g[j] = loc_g[j];
            }
            for(int rankid = 1; rankid < num_proc; rankid++){//receive other node`s gradient and store to glo_g;
                MPI_Recv(loc_g, data->glo_fea_dim, MPI_FLOAT, rankid, 99, MPI_COMM_WORLD, &status);
                for(int j = 0; j < data->glo_fea_dim; j++){
                    glo_g[j] += loc_g[j];
                }
            }
            for(int j = 0; j < data->glo_fea_dim; j++){
                glo_g[j] /= num_proc;
            }
            //update parameter
            for(int col = 0; col < data->glo_fea_dim; col++){
                //the first update sigma, z, n
                loc_sigma[col] = ( sqrt (loc_n[col] + glo_g[col] * glo_g[col]) - sqrt(loc_n[col]) ) / alpha;
                loc_z[col] += glo_g[col] - loc_sigma[col] * loc_w[col];
                loc_n[col] += glo_g[col] * glo_g[col];
                //the secondary update w
                if(abs(loc_z[col]) <= lambda1){
                    loc_w[col] = 0.0;
                }
                else{
                    float tmpr= 0.0;
                    if(loc_z[col] >= 0) tmpr = loc_z[col] - lambda1;
                    else tmpr = loc_z[col] + lambda1;
                    float tmpl = -1 * ( ( beta + sqrt(loc_n[col]) ) / alpha  + lambda2);
                    loc_w[col] = tmpr / tmpl;
                }
            }
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x2a0(%rax), %rsi
testq %rsi, %rsi
jle 0x3a46
movq 0x58(%rbx), %rax
movq 0x60(%rbx), %rcx
xorl %edx, %edx
movss (%rax,%rdx,4), %xmm0
movss %xmm0, (%rcx,%rdx,4)
incq %rdx
cmpq %rdx, %rsi
jne 0x3a34
movl 0x80(%rbx), %eax
cmpl $0x2, %eax
jl 0x3ac4
leaq 0x28(%rbx), %r13
movl $0x1, %r14d
movq 0x355e(%rip), %r15      # 0x6fc0
movq 0x3547(%rip), %r12      # 0x6fb0
movq 0x58(%rbx), %rdi
movq %r13, (%rsp)
movq %r15, %rdx
movl %r14d, %ecx
movl $0x63, %r8d
movq %r12, %r9
callq 0x2180
movq 0x40(%rbx), %rax
movq 0x2a0(%rax), %rsi
testq %rsi, %rsi
jle 0x3ab6
movq 0x58(%rbx), %rax
movq 0x60(%rbx), %rcx
xorl %edx, %edx
movss (%rax,%rdx,4), %xmm0
addss (%rcx,%rdx,4), %xmm0
movss %xmm0, (%rcx,%rdx,4)
incq %rdx
cmpq %rdx, %rsi
jne 0x3a9f
incl %r14d
movl 0x80(%rbx), %eax
cmpl %eax, %r14d
jl 0x3a69
testq %rsi, %rsi
jle 0x3c53
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movq 0x60(%rbx), %rax
xorl %ecx, %ecx
movss (%rax,%rcx,4), %xmm1
divss %xmm0, %xmm1
movss %xmm1, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %rsi
jne 0x3ada
testq %rsi, %rsi
jle 0x3c53
xorl %r14d, %r14d
xorps %xmm2, %xmm2
movq 0x60(%rbx), %rax
movq 0x78(%rbx), %rcx
movss (%rax,%r14,4), %xmm0
mulss %xmm0, %xmm0
addss (%rcx,%r14,4), %xmm0
ucomiss %xmm2, %xmm0
jb 0x3b25
xorps %xmm1, %xmm1
sqrtss %xmm0, %xmm1
jmp 0x3b30
callq 0x2340
xorps %xmm2, %xmm2
movaps %xmm0, %xmm1
movq 0x78(%rbx), %rax
movss (%rax,%r14,4), %xmm0
ucomiss %xmm2, %xmm0
jb 0x3b45
sqrtss %xmm0, %xmm0
jmp 0x3b57
movss %xmm1, -0x40(%rbp)
callq 0x2340
movss -0x40(%rbp), %xmm1
xorps %xmm2, %xmm2
subss %xmm0, %xmm1
divss 0x14(%rbx), %xmm1
movq 0x70(%rbx), %rax
movss %xmm1, (%rax,%r14,4)
movq (%rbx), %rax
movq 0x60(%rbx), %rcx
movss (%rcx,%r14,4), %xmm0
mulss (%rax,%r14,4), %xmm1
subss %xmm1, %xmm0
movq 0x68(%rbx), %rdx
addss (%rdx,%r14,4), %xmm0
movss %xmm0, (%rdx,%r14,4)
movss (%rcx,%r14,4), %xmm0
movq 0x78(%rbx), %rcx
mulss %xmm0, %xmm0
addss (%rcx,%r14,4), %xmm0
movss %xmm0, (%rcx,%r14,4)
movss (%rdx,%r14,4), %xmm4
movaps %xmm4, %xmm1
andps 0x1475(%rip), %xmm1     # 0x5030
movss 0x1c(%rbx), %xmm6
ucomiss %xmm1, %xmm6
jae 0x3bd5
movss 0x18(%rbx), %xmm5
ucomiss %xmm2, %xmm0
jb 0x3bdf
sqrtss %xmm0, %xmm0
jmp 0x3bff
movl $0x0, (%rax,%r14,4)
jmp 0x3c3f
movaps %xmm4, -0x40(%rbp)
movaps %xmm5, -0x60(%rbp)
movaps %xmm6, -0x50(%rbp)
callq 0x2340
movaps -0x50(%rbp), %xmm6
movaps -0x60(%rbp), %xmm5
movaps -0x40(%rbp), %xmm4
xorps %xmm2, %xmm2
addss %xmm0, %xmm5
xorps %xmm0, %xmm0
cmpnless %xmm4, %xmm0
movaps %xmm0, %xmm1
andps %xmm6, %xmm1
movaps 0x1428(%rip), %xmm3     # 0x5040
xorps %xmm3, %xmm6
andnps %xmm6, %xmm0
orps %xmm1, %xmm0
addss %xmm4, %xmm0
divss 0x14(%rbx), %xmm5
addss 0x20(%rbx), %xmm5
xorps %xmm3, %xmm5
divss %xmm5, %xmm0
movq (%rbx), %rax
movss %xmm0, (%rax,%r14,4)
incq %r14
movq 0x40(%rbx), %rax
cmpq %r14, 0x2a0(%rax)
jg 0x3aff
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq