int main(int argc, char *argv[]) { log_options_t log_opts = LOG_OPTS_INITIALIZER; hostlist_t hl = NULL; char *node_name; pthread_attr_t attr_work; pthread_t thread_work = 0; xstrfmtcat(prog_name, "%s[%u]", argv[0], (uint32_t) getpid()); _read_config(); log_opts.stderr_level = LOG_LEVEL_QUIET; log_opts.syslog_level = LOG_LEVEL_QUIET; if (slurm_get_debug_flags() && DEBUG_FLAG_NODE_FEATURES) log_opts.logfile_level += 3; (void) log_init(argv[0], log_opts, LOG_DAEMON, log_file); if ((hl = hostlist_create(argv[1])) == NULL) { error("%s: Invalid hostlist (%s)", prog_name, argv[1]); exit(2); } while ((node_name = hostlist_pop(hl))) { slurm_mutex_lock(&thread_cnt_mutex); while (1) { if (thread_cnt <= MAX_THREADS) { thread_cnt++; break; } else { /* wait for state change and retry */ pthread_cond_wait(&thread_cnt_cond, &thread_cnt_mutex); } } slurm_mutex_unlock(&thread_cnt_mutex); slurm_attr_init(&attr_work); (void) pthread_attr_setdetachstate (&attr_work, PTHREAD_CREATE_DETACHED); if (pthread_create(&thread_work, &attr_work, _node_update, (void *) node_name)) { _node_update((void *) node_name); } slurm_attr_destroy(&attr_work); } /* Wait for work threads to complete */ slurm_mutex_lock(&thread_cnt_mutex); while (1) { if (thread_cnt == 0) break; else /* wait for state change and retry */ pthread_cond_wait(&thread_cnt_cond, &thread_cnt_mutex); } slurm_mutex_unlock(&thread_cnt_mutex); hostlist_destroy(hl); exit(0); }
int main(int argc, char *argv[]) { log_options_t log_opts = LOG_OPTS_INITIALIZER; char *features, *save_ptr = NULL, *tok; update_node_msg_t node_msg; int rc = SLURM_SUCCESS; hostlist_t hl = NULL; char *node_name; pthread_attr_t attr_work; pthread_t thread_work = 0; prog_name = argv[0]; _read_config(); log_opts.stderr_level = LOG_LEVEL_QUIET; log_opts.syslog_level = LOG_LEVEL_QUIET; if (slurm_get_debug_flags() && DEBUG_FLAG_NODE_FEATURES) log_opts.logfile_level += 3; (void) log_init(argv[0], log_opts, LOG_DAEMON, log_file); /* Parse the MCDRAM and NUMA boot options */ if (argc == 3) { features = xstrdup(argv[2]); tok = strtok_r(features, ",", &save_ptr); while (tok) { printf("%s\n", tok); if (!strcasecmp(tok, "a2a") || !strcasecmp(tok, "hemi") || !strcasecmp(tok, "quad") || !strcasecmp(tok, "snc2") || !strcasecmp(tok, "snc4")) { xfree(mcdram_mode); mcdram_mode = xstrdup(tok); } else if (!strcasecmp(tok, "cache") || !strcasecmp(tok, "equal") || !strcasecmp(tok, "flat")) { xfree(numa_mode); numa_mode = xstrdup(tok); } tok = strtok_r(NULL, ",", &save_ptr); } xfree(features); } /* Spawn threads to change MCDRAM and NUMA states and start node * reboot process */ if ((hl = hostlist_create(argv[1])) == NULL) { error("%s: Invalid hostlist (%s)", prog_name, argv[1]); exit(2); } node_bitmap = bit_alloc(100000); while ((node_name = hostlist_pop(hl))) { slurm_mutex_lock(&thread_cnt_mutex); while (1) { if (thread_cnt <= MAX_THREADS) { thread_cnt++; break; } else { /* wait for state change and retry */ pthread_cond_wait(&thread_cnt_cond, &thread_cnt_mutex); } } slurm_mutex_unlock(&thread_cnt_mutex); slurm_attr_init(&attr_work); (void) pthread_attr_setdetachstate (&attr_work, PTHREAD_CREATE_DETACHED); if (pthread_create(&thread_work, &attr_work, _node_update, (void *) node_name)) { _node_update((void *) node_name); } slurm_attr_destroy(&attr_work); } /* Wait for work threads to complete */ slurm_mutex_lock(&thread_cnt_mutex); while (1) { if (thread_cnt == 0) break; else /* wait for state change and retry */ pthread_cond_wait(&thread_cnt_cond, &thread_cnt_mutex); } slurm_mutex_unlock(&thread_cnt_mutex); hostlist_destroy(hl); xfree(mcdram_mode); xfree(numa_mode); /* Wait for all nodes to change state to "on" */ _wait_all_nodes_on(); if ((argc == 3) && !syscfg_path) { slurm_init_update_node_msg(&node_msg); node_msg.node_names = argv[1]; node_msg.features_act = argv[2]; rc = slurm_update_node(&node_msg); } if (rc == SLURM_SUCCESS) { exit(0); } else { error("%s: slurm_update_node(\'%s\', \'%s\'): %s\n", prog_name, argv[1], argv[2], slurm_strerror(slurm_get_errno())); exit(1); } }