// File: /workspace/github_cpp_makefile_star2_O3/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 0x116270
cmpq $0x0, (%rbx)
je 0x11b6f9
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 0x11b982
movq %r13, %rdi
movq %r15, %rsi
callq 0x11b944
cmpq $0x0, 0x8(%rsp)
jne 0x11b808
incq %rbp
cmpq (%rbx), %rbp
jb 0x11b6aa
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %r12, %r15
je 0x11b6f9
movq %r15, %rdi
callq 0x116140
addq $0x8, %r15
jmp 0x11b6e6
leaq 0x48(%rsp), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x116270
leaq 0x2f8701(%rip), %rcx    # 0x413e10
xorl %eax, %eax
addq (%r15,%rcx), %rax
addq $0x28, %r15
cmpq $0x640, %r15            # imm = 0x640
jne 0x11b711
movq (%r14), %rdx
movq (%rbx), %rcx
movq 0x48(%rsp), %rsi
subq 0x38(%rsp), %rsi
jge 0x11b746
movsd 0x1928cc(%rip), %xmm2   # 0x2ae008
movsd 0x1928cc(%rip), %xmm0   # 0x2ae010
jmp 0x11b78c
imulq $0xf4240, %rsi, %rsi    # imm = 0xF4240
addq 0x50(%rsp), %rsi
subq 0x40(%rsp), %rsi
movq %rsi, %xmm1
punpckldq 0x19298c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x192994(%rip), %xmm1   # 0x2ae100
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x192898(%rip), %xmm0   # 0x2ae018
movsd 0x192898(%rip), %xmm2   # 0x2ae020
mulsd %xmm0, %xmm2
imulq %rdx, %rax
imulq %rcx, %rax
imulq $0x7d0, %rax, %rsi      # imm = 0x7D0
movq %rsi, %xmm3
punpckldq 0x192948(%rip), %xmm3 # xmm3 = xmm3[0],mem[0],xmm3[1],mem[1]
subpd 0x192950(%rip), %xmm3   # 0x2ae100
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
addsd %xmm3, %xmm1
divsd %xmm2, %xmm1
leaq 0x1974c9(%rip), %rdi    # 0x2b2c90
movb $0x2, %al
callq 0x116050
leaq 0x10(%rsp), %rdi
callq 0x11b9f0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11b7f3
jmp 0x11b7f3
cmpq $0x0, 0x8(%rsp)
jne 0x11b808
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x11b9f0
movq %rbx, %rdi
callq 0x116320
callq 0x116550
nop