Lines Matching refs:g
50 #define tprintf(x...) do { if (g && g->p.show_details >= 0) printf(x); } while (0)
56 #define dprintf(x...) do { if (g && g->p.show_details >= 1) printf(x); } while (0)
164 static struct global_info *g = NULL;
233 for (i = 0; i < g->p.nr_nodes; i++) {
295 for (cpu = 0; cpu < g->p.nr_cpus; cpu++)
298 if (target_cpu < 0 || target_cpu >= g->p.nr_cpus)
341 for (cpu = 0; cpu < g->p.nr_cpus; cpu++)
389 ret = set_mempolicy(MPOL_DEFAULT, NULL, g->p.nr_nodes-1);
452 if (ret && !g->print_once) {
453 g->print_once = 1;
459 if (ret && !g->print_once) {
460 g->print_once = 1;
509 return alloc_data(bytes, MAP_SHARED, 1, g->p.init_cpu0, g->p.thp, g->p.init_random);
517 return alloc_data(bytes, MAP_SHARED, 0, g->p.init_cpu0, g->p.thp, g->p.init_random);
526 return alloc_data(bytes, MAP_PRIVATE, 0, g->p.init_cpu0, g->p.thp, g->p.init_random);
595 if (!g->p.cpu_list_str)
598 dprintf("g->p.nr_tasks: %d\n", g->p.nr_tasks);
600 str0 = str = strdup(g->p.cpu_list_str);
635 BUG_ON(step <= 0 || step >= g->p.nr_cpus);
647 BUG_ON(bind_len <= 0 || bind_len > g->p.nr_cpus);
660 if (bind_cpu_0 >= g->p.nr_cpus || bind_cpu_1 >= g->p.nr_cpus) {
661 printf("\nTest not applicable, system has only %d CPUs.\n", g->p.nr_cpus);
674 size_t size = CPU_ALLOC_SIZE(g->p.nr_cpus);
680 if (t >= g->p.nr_tasks) {
684 td = g->threads + t;
694 td->bind_cpumask = CPU_ALLOC(g->p.nr_cpus);
698 if (cpu < 0 || cpu >= g->p.nr_cpus) {
712 if (t < g->p.nr_tasks)
713 printf("# NOTE: %d tasks bound, %d tasks unbound\n", t, g->p.nr_tasks - t);
743 if (!g->p.node_list_str)
746 dprintf("g->p.nr_tasks: %d\n", g->p.nr_tasks);
748 str0 = str = strdup(g->p.node_list_str);
782 BUG_ON(step <= 0 || step >= g->p.nr_nodes);
795 if (bind_node_0 >= g->p.nr_nodes || bind_node_1 >= g->p.nr_nodes) {
796 printf("\nTest not applicable, system has only %d nodes.\n", g->p.nr_nodes);
807 if (t >= g->p.nr_tasks || !node_has_cpus(bind_node)) {
811 td = g->threads + t;
827 if (t < g->p.nr_tasks)
828 printf("# NOTE: %d tasks mem-bound, %d tasks unbound\n", t, g->p.nr_tasks - t);
857 if (g->p.data_reads)
859 if (g->p.data_writes)
888 if (g->p.data_zero_memset && !g->p.data_rand_walk) {
895 chunk_1 = words/g->p.nr_loops;
901 if (g->p.data_rand_walk) {
913 if (g->p.data_zero_memset) {
920 } else if (!g->p.data_backwards || (nr + loop) & 1) {
965 g->threads[task_nr].curr_cpu = cpu;
974 * to a single node. A count of g->p.nr_nodes means it's
983 node_present = (char *)malloc(g->p.nr_nodes * sizeof(char));
985 for (nodes = 0; nodes < g->p.nr_nodes; nodes++)
988 for (t = 0; t < g->p.nr_threads; t++) {
993 task_nr = process_nr*g->p.nr_threads + t;
994 td = g->threads + task_nr;
1007 for (n = 0; n < g->p.nr_nodes; n++)
1026 for (p = 0; p < g->p.nr_proc; p++) {
1027 for (t = 0; t < g->p.nr_threads; t++) {
1032 task_nr = p*g->p.nr_threads + t;
1033 td = g->threads + task_nr;
1054 for (p = 0; p < g->p.nr_proc; p++) {
1090 if (!g->p.show_convergence && !g->p.measure_convergence)
1093 nodes = (int *)malloc(g->p.nr_nodes * sizeof(int));
1095 for (node = 0; node < g->p.nr_nodes; node++)
1101 for (t = 0; t < g->p.nr_tasks; t++) {
1102 struct thread_data *td = g->threads + t;
1121 nr_min = g->p.nr_tasks;
1124 for (node = 0; node < g->p.nr_nodes; node++) {
1134 BUG_ON(sum > g->p.nr_tasks);
1136 if (0 && (sum < g->p.nr_tasks)) {
1144 * to g->p.nr_proc:
1148 for (node = 0; node < g->p.nr_nodes; node++) {
1175 if (strong && process_groups == g->p.nr_proc) {
1179 if (g->p.measure_convergence) {
1180 g->all_converged = true;
1181 g->stop_work = true;
1198 (double)(l+1)/g->p.nr_loops*100.0, runtime_ns_max / NSEC_PER_SEC / 60.0);
1202 if (g->p.show_details >= 0)
1214 int details = g->p.show_details;
1232 global_data = g->data;
1234 thread_data = setup_private_data(g->p.bytes_thread);
1239 if (process_nr == g->p.nr_proc-1 && thread_nr == g->p.nr_threads-1)
1251 if (g->p.serialize_startup) {
1252 mutex_lock(&g->startup_mutex);
1253 g->nr_tasks_started++;
1255 if (g->nr_tasks_started == g->p.nr_tasks)
1256 cond_signal(&g->startup_cond);
1258 mutex_unlock(&g->startup_mutex);
1261 mutex_lock(&g->start_work_mutex);
1262 g->start_work = false;
1263 g->nr_tasks_working++;
1264 while (!g->start_work)
1265 cond_wait(&g->start_work_cond, &g->start_work_mutex);
1267 mutex_unlock(&g->start_work_mutex);
1275 for (l = 0; l < g->p.nr_loops; l++) {
1278 if (g->stop_work)
1281 val += do_work(global_data, g->p.bytes_global, process_nr, g->p.nr_proc, l, val);
1282 val += do_work(process_data, g->p.bytes_process, thread_nr, g->p.nr_threads, l, val);
1283 val += do_work(thread_data, g->p.bytes_thread, 0, 1, l, val);
1285 if (g->p.sleep_usecs) {
1287 usleep(g->p.sleep_usecs);
1293 if (g->p.bytes_process_locked) {
1295 val += do_work(process_data, g->p.bytes_process_locked, thread_nr, g->p.nr_threads, l, val);
1299 work_done = g->p.bytes_global + g->p.bytes_process +
1300 g->p.bytes_process_locked + g->p.bytes_thread;
1305 if (details < 0 && !g->p.perturb_secs && !g->p.measure_convergence && !g->p.nr_secs)
1313 if (g->p.nr_secs) {
1315 if ((u32)diff.tv_sec >= g->p.nr_secs) {
1316 g->stop_work = true;
1326 * Perturb the first task's equilibrium every g->p.perturb_secs seconds,
1329 if (first_task && g->p.perturb_secs && (int)(stop.tv_sec - last_perturbance) >= g->p.perturb_secs) {
1341 this_cpu = g->threads[task_nr].curr_cpu;
1342 if (this_cpu < g->p.nr_cpus/2)
1343 target_cpu = g->p.nr_cpus-1;
1391 free_data(thread_data, g->p.bytes_thread);
1393 mutex_lock(&g->stop_work_mutex);
1394 g->bytes_done += bytes_done;
1395 mutex_unlock(&g->stop_work_mutex);
1420 task_nr = process_nr*g->p.nr_threads;
1421 td = g->threads + task_nr;
1426 pthreads = zalloc(g->p.nr_threads * sizeof(pthread_t));
1427 process_data = setup_private_data(g->p.bytes_process);
1429 if (g->p.show_details >= 3) {
1431 process_nr, g->data, process_data);
1434 for (t = 0; t < g->p.nr_threads; t++) {
1435 task_nr = process_nr*g->p.nr_threads + t;
1436 td = g->threads + task_nr;
1450 for (t = 0; t < g->p.nr_threads; t++) {
1455 free_data(process_data, g->p.bytes_process);
1461 if (g->p.show_details < 0)
1466 g->p.nr_tasks, g->p.nr_tasks == 1 ? "task" : "tasks", nr_numa_nodes(), g->p.nr_cpus);
1468 g->p.nr_loops, g->p.bytes_global/1024/1024);
1470 g->p.nr_loops, g->p.bytes_process/1024/1024);
1472 g->p.nr_loops, g->p.bytes_thread/1024/1024);
1481 ssize_t size = sizeof(*g->threads)*g->p.nr_tasks;
1484 g->threads = zalloc_shared_data(size);
1486 for (t = 0; t < g->p.nr_tasks; t++) {
1487 struct thread_data *td = g->threads + t;
1488 size_t cpuset_size = CPU_ALLOC_SIZE(g->p.nr_cpus);
1495 td->bind_cpumask = CPU_ALLOC(g->p.nr_cpus);
1498 for (cpu = 0; cpu < g->p.nr_cpus; cpu++)
1505 ssize_t size = sizeof(*g->threads)*g->p.nr_tasks;
1509 for (t = 0; t < g->p.nr_tasks; t++) {
1510 struct thread_data *td = g->threads + t;
1514 free_data(g->threads, size);
1519 g = (void *)alloc_data(sizeof(*g), MAP_SHARED, 1, 0, 0 /* THP */, 0);
1522 g->p = p0;
1524 g->p.nr_cpus = numa_num_configured_cpus();
1526 g->p.nr_nodes = numa_max_node() + 1;
1529 BUG_ON(g->p.nr_nodes < 0);
1531 if (quiet && !g->p.show_details)
1532 g->p.show_details = -1;
1535 if (!g->p.mb_global_str && !g->p.mb_proc_str && !g->p.mb_thread_str)
1538 if (g->p.mb_global_str) {
1539 g->p.mb_global = atof(g->p.mb_global_str);
1540 BUG_ON(g->p.mb_global < 0);
1543 if (g->p.mb_proc_str) {
1544 g->p.mb_proc = atof(g->p.mb_proc_str);
1545 BUG_ON(g->p.mb_proc < 0);
1548 if (g->p.mb_proc_locked_str) {
1549 g->p.mb_proc_locked = atof(g->p.mb_proc_locked_str);
1550 BUG_ON(g->p.mb_proc_locked < 0);
1551 BUG_ON(g->p.mb_proc_locked > g->p.mb_proc);
1554 if (g->p.mb_thread_str) {
1555 g->p.mb_thread = atof(g->p.mb_thread_str);
1556 BUG_ON(g->p.mb_thread < 0);
1559 BUG_ON(g->p.nr_threads <= 0);
1560 BUG_ON(g->p.nr_proc <= 0);
1562 g->p.nr_tasks = g->p.nr_proc*g->p.nr_threads;
1564 g->p.bytes_global = g->p.mb_global *1024L*1024L;
1565 g->p.bytes_process = g->p.mb_proc *1024L*1024L;
1566 g->p.bytes_process_locked = g->p.mb_proc_locked *1024L*1024L;
1567 g->p.bytes_thread = g->p.mb_thread *1024L*1024L;
1569 g->data = setup_shared_data(g->p.bytes_global);
1572 mutex_init_pshared(&g->start_work_mutex);
1573 cond_init_pshared(&g->start_work_cond);
1574 mutex_init_pshared(&g->startup_mutex);
1575 cond_init_pshared(&g->startup_cond);
1576 mutex_init_pshared(&g->stop_work_mutex);
1592 free_data(g->data, g->p.bytes_global);
1593 g->data = NULL;
1597 free_data(g, sizeof(*g));
1598 g = NULL;
1632 pids = zalloc(g->p.nr_proc * sizeof(*pids));
1635 if (g->p.serialize_startup) {
1642 for (i = 0; i < g->p.nr_proc; i++) {
1657 if (g->p.serialize_startup) {
1665 mutex_lock(&g->startup_mutex);
1666 while (g->nr_tasks_started != g->p.nr_tasks)
1667 cond_wait(&g->startup_cond, &g->startup_mutex);
1669 mutex_unlock(&g->startup_mutex);
1673 mutex_lock(&g->start_work_mutex);
1674 threads_ready = (g->nr_tasks_working == g->p.nr_tasks);
1675 mutex_unlock(&g->start_work_mutex);
1693 mutex_lock(&g->start_work_mutex);
1694 g->start_work = true;
1695 mutex_unlock(&g->start_work_mutex);
1696 cond_broadcast(&g->start_work_cond);
1704 for (i = 0; i < g->p.nr_proc; i++) {
1714 for (t = 0; t < g->p.nr_tasks; t++) {
1715 u64 thread_runtime_ns = g->threads[t].runtime_ns;
1735 bytes = g->bytes_done;
1736 runtime_avg = (double)runtime_ns_sum / g->p.nr_tasks / NSEC_PER_SEC;
1738 if (g->p.measure_convergence) {
1756 print_res(name, bytes / g->p.nr_tasks / 1e9,
1762 print_res(name, runtime_sec_max * NSEC_PER_SEC / (bytes / g->p.nr_tasks),
1765 print_res(name, bytes / g->p.nr_tasks / 1e9 / runtime_sec_max,
1771 if (g->p.show_details >= 2) {
1774 for (p = 0; p < g->p.nr_proc; p++) {
1775 for (t = 0; t < g->p.nr_threads; t++) {
1777 td = g->threads + p*g->p.nr_threads + t;