// File: /workspace/github_cpp_makefile_star2_O1/ArashPartow[P]exprtk-extras/exprtk_vector_benchmark_multithreaded.cpp
// Function: void run_threaded_benchmark<double>(unsigned long const&, unsigned long const&)
void run_threaded_benchmark(const std::size_t& vec_size, const std::size_t& thread_count)
{
   std::vector<std::thread> thread_list;

   exprtk::timer timer;

   timer.start();

   for (std::size_t i = 0; i < thread_count; ++i)
   {
      thread_list.emplace_back(
         std::thread([vec_size]()
                     {
                        for (std::size_t e = 0; e < global_expression_list_size; ++e)
                        {
                           run_expression_benchmark<T>(
                              vec_size,
                              global_expression_list[e].expression,
                              global_expression_list[e].cost);
                        }
                     }));
   }

   for (auto& t : thread_list)
   {
      t.join();
   }

   timer.stop();

   unsigned long long total_flops = 0;

   for (std::size_t i = 0; i < global_expression_list_size; ++i)
   {
      total_flops += global_expression_list[i].cost;
   }

   total_flops = (total_flops * rounds * vec_size * thread_count);

   printf("Total Time:%10.7f FLOP: %llu Perf: %7.4fGFLOPS\n",
          timer.time(),
          total_flops,
          total_flops / (1e9 * timer.time()));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x38(%rsp), %rdi
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movb $0x1, -0x8(%rdi)
xorl %esi, %esi
callq 0x118270
cmpq $0x0, (%rbx)
je 0x11d72c
xorl %ebp, %ebp
leaq 0x8(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x10(%rsp), %r13
movq (%r14), %rax
movq %rax, 0x28(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x11da10
movq %r13, %rdi
movq %r15, %rsi
callq 0x11d9d4
cmpq $0x0, 0x8(%rsp)
jne 0x11d88d
incq %rbp
cmpq (%rbx), %rbp
jb 0x11d6fa
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %r12, %r15
je 0x11d749
movq %r15, %rdi
callq 0x118140
addq $0x8, %r15
jmp 0x11d736
leaq 0x48(%rsp), %r15
xorl %r12d, %r12d
movq %r15, %rdi
xorl %esi, %esi
callq 0x118270
movb $0x0, -0x18(%r15)
leaq 0x32a6a9(%rip), %rcx    # 0x447e10
xorl %eax, %eax
addq (%r12,%rcx), %rax
addq $0x28, %r12
cmpq $0x640, %r12            # imm = 0x640
jne 0x11d769
movq 0x48(%rsp), %rcx
subq 0x38(%rsp), %rcx
jge 0x11d790
movsd 0x1b387a(%rip), %xmm0   # 0x2d1008
jmp 0x11d7ca
imulq $0xf4240, %rcx, %rcx    # imm = 0xF4240
addq 0x50(%rsp), %rcx
subq 0x40(%rsp), %rcx
movq %rcx, %xmm1
punpckldq 0x1b3942(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1b394a(%rip), %xmm1   # 0x2d1100
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x1b3846(%rip), %xmm0   # 0x2d1010
movq (%r14), %rdx
movq (%rbx), %rcx
movq 0x48(%rsp), %rsi
subq 0x38(%rsp), %rsi
jge 0x11d7e6
movsd 0x1b3834(%rip), %xmm2   # 0x2d1018
jmp 0x11d828
imulq $0xf4240, %rsi, %rsi    # imm = 0xF4240
addq 0x50(%rsp), %rsi
subq 0x40(%rsp), %rsi
movq %rsi, %xmm1
punpckldq 0x1b38ec(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1b38f4(%rip), %xmm1   # 0x2d1100
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0x1b37f0(%rip), %xmm2   # 0x2d1010
mulsd 0x1b37f8(%rip), %xmm2   # 0x2d1020
imulq %rdx, %rax
imulq %rcx, %rax
imulq $0x7d0, %rax, %rsi      # imm = 0x7D0
movq %rsi, %xmm3
punpckldq 0x1b38ac(%rip), %xmm3 # xmm3 = xmm3[0],mem[0],xmm3[1],mem[1]
subpd 0x1b38b4(%rip), %xmm3   # 0x2d1100
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
addsd %xmm3, %xmm1
divsd %xmm2, %xmm1
leaq 0x1b83c5(%rip), %rdi    # 0x2d5c28
movb $0x2, %al
callq 0x118050
leaq 0x10(%rsp), %rdi
callq 0x11da8e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11d892
cmpq $0x0, 0x8(%rsp)
je 0x11d892
callq 0x118550
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x11da8e
movq %rbx, %rdi
callq 0x118320
nop