char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
7b95ea5d1
char/aliceai-t5-moe
1#include "log.h" 2 3#include <cstdlib> 4#include <thread> 5 6int main () { 7const int n_thread = 8 ; 8 9 std::thread threads [n_thread ]; 10for (int i = 0 ;i < n_thread ;i ++ ) { 11threads [i ]= std::thread ([i ]() { 12const int n_msg = 1000 ; 13 14for (int j = 0 ;j < n_msg ;j ++ ) { 15const int log_type = std::rand () %4 ; 16 17switch (log_type ) { 18case 0 :LOG_INF ("Thread %d: %d\n" ,i ,j );break ; 19case 1 :LOG_WRN ("Thread %d: %d\n" ,i ,j );break ; 20case 2 :LOG_ERR ("Thread %d: %d\n" ,i ,j );break ; 21case 3 :LOG_DBG ("Thread %d: %d\n" ,i ,j );break ; 22default : 23break ; 24 } 25 26if (rand () %10 < 5 ) { 27common_log_set_timestamps (common_log_main (),rand () %2 ); 28common_log_set_prefix (common_log_main (),rand () %2 ); 29 } 30 } 31 }); 32 } 33 34for (int i = 0 ;i < n_thread ;i ++ ) { 35threads [i ].join (); 36 } 37 38common_log_flush (common_log_main ()); 39// We explicitly free the logger singleton to avoid hanging on Windows 40// related to timing issues of thread startup and DLL teardown 41common_log_free (common_log_main ()); 42return 0 ; 43}