/* Try to start the job on any non-reserved nodes */ static int _start_job(struct job_record *job_ptr, bitstr_t *resv_bitmap) { int rc; bitstr_t *orig_exc_nodes = NULL; static uint32_t fail_jobid = 0; if (job_ptr->details->exc_node_bitmap) { orig_exc_nodes = bit_copy(job_ptr->details->exc_node_bitmap); bit_or(job_ptr->details->exc_node_bitmap, resv_bitmap); } else job_ptr->details->exc_node_bitmap = bit_copy(resv_bitmap); rc = select_nodes(job_ptr, false, NULL); if (job_ptr->details) { /* select_nodes() might cancel the job! */ FREE_NULL_BITMAP(job_ptr->details->exc_node_bitmap); job_ptr->details->exc_node_bitmap = orig_exc_nodes; } else FREE_NULL_BITMAP(orig_exc_nodes); if (rc == SLURM_SUCCESS) { /* job initiated */ last_job_update = time(NULL); info("backfill: Started JobId=%u on %s", job_ptr->job_id, job_ptr->nodes); if (job_ptr->batch_flag == 0) srun_allocate(job_ptr->job_id); else if ((job_ptr->details == NULL) || (job_ptr->details->prolog_running == 0)) launch_job(job_ptr); slurmctld_diag_stats.backfilled_jobs++; slurmctld_diag_stats.last_backfilled_jobs++; if (debug_flags & DEBUG_FLAG_BACKFILL) { info("backfill: Jobs backfilled since boot: %u", slurmctld_diag_stats.backfilled_jobs); } } else if ((job_ptr->job_id != fail_jobid) && (rc != ESLURM_ACCOUNTING_POLICY)) { char *node_list; bit_not(resv_bitmap); node_list = bitmap2node_name(resv_bitmap); /* This happens when a job has sharing disabled and * a selected node is still completing some job, * which should be a temporary situation. */ verbose("backfill: Failed to start JobId=%u on %s: %s", job_ptr->job_id, node_list, slurm_strerror(rc)); xfree(node_list); fail_jobid = job_ptr->job_id; } else { debug3("backfill: Failed to start JobId=%u: %s", job_ptr->job_id, slurm_strerror(rc)); } return rc; }
int main() { list_node *token_list; token current_token; job *job_list; init_tokenizer(stdin); init_shell(); while (1) { fprintf(stdout, "myshell>"); token_list = create_list(sizeof(token)); //字句解析を行なってリストに追加する while ((current_token = get_token()).kind != token_type_eol && current_token.kind != token_type_eof) { add_list(token_list, ¤t_token); } request_job_notification (); if (token_list->next == NULL) { p_debug("continue"); continue; } //字句解析結果を表示 //dump_token_list_data(token_list); //構文解析を行う job_list = parse(token_list); //実行 launch_job(job_list); free_list(token_list); } }
int main(int argc, char ** argvFILE) { char line[1024]; /* the input line */ char *argv[64]; /* the command line argument */ char * p; int tokens, foreground; int * ptokens =&tokens; int * pforeground =&foreground; int input_from_file = ftell(stdin); /* check if input is coming from file */ init_shell(); while (1) { /* repeat until done .... */ if(input_from_file < 0) /* stdin is coming from user not file */ printf("sish:>"); /* display a prompt */ memset (line, '\0', sizeof(line)); // zero line, (fills array with null terminator) memset (argv, '\0', sizeof(argv)); if (!fgets(line, sizeof(line), stdin)) {printf("\n"); return 0;} // Exit upon ctrl-D if(strlen(line) == 1) { continue; // check for empty string aka 'enter' is pressed without input } if ((p = strchr(line, '\n')) != NULL) // remove '\n' from the end of 'line' *p = '\0'; parse (line, argv, ptokens); // parse input to shell if (argv[0] == '\0') continue; else if (strcmp(argv[0], "exit") == 0) /* is it an "exit"? */ return 0; /* exit if it is */ else if (strcmp(argv[0], "cd") == 0) cd (argv[1]); else { if ((first_job = job_initialize(argv, tokens, pforeground)) != NULL) { launch_job (first_job, foreground); free_job(first_job); } } } }
void test_mm(void) { int max_threads = 8; thread_pool_t *thread_pool = create_thread_pool(max_threads); int m = 8192; int n = 1024; int k = 1024; double *a = make_array(m, k); double *b = make_array(k, n); double *o = make_array(m, n); int tile_sizes[5] = {1024, 64, 64, 8, 8}; int num_threads = 8; job_t *job = make_job(0, m, 1024, num_threads, 1); vm_args_t vm_args; vm_args.a = a; vm_args.b = b; vm_args.out = o; vm_args.m = m; vm_args.n = n; vm_args.k = k; struct timeval start, end, result; gettimeofday(&start, NULL); launch_job(thread_pool, &vm2, &vm_args, job, tile_sizes, 1); wait_for_job(thread_pool); gettimeofday(&end, NULL); double t; timersub(&end, &start, &result); t = result.tv_sec + result.tv_usec / 1000000.0; printf("Parallel runtime: %f\n", t); int pass = 1; // int i, j, l; // double sum; // gettimeofday(&start, NULL); // for (i = 0; i < m; ++i) { // for (j = 0; j < n; ++j) { // sum = 0.0; // for (l = 0; l < k; ++l) { // sum += a[i*k + l] * b[j*k + l]; // } // pass = pass && (abs(sum - o[i*n + j]) < 1e-4); // } // } // gettimeofday(&end, NULL); CU_ASSERT(pass); // double naive_time; // timersub(&end, &start, &result); // naive_time = result.tv_sec + result.tv_usec / 1000000.0; // printf("Naive time: %f\n", naive_time); destroy_thread_pool(thread_pool); free_job(job); free_array(a); free_array(b); free_array(o); }
int main(int argc, char ** argv, char * envp[]) { struct pisces_cmd cmd; int pisces_fd = 0; memset(&cmd, 0, sizeof(struct pisces_cmd)); printf("Pisces Control Daemon\n"); CPU_ZERO(&enclave_cpus); /* Initialize CPU mask */ CPU_SET(0, &enclave_cpus); /* We always boot on CPU 0 */ pisces_fd = open(PISCES_CMD_PATH, O_RDWR); if (pisces_fd < 0) { printf("Error opening pisces cmd file (%s)\n", PISCES_CMD_PATH); return -1; } while (1) { int ret = 0; ret = read(pisces_fd, &cmd, sizeof(struct pisces_cmd)); if (ret != sizeof(struct pisces_cmd)) { printf("Error reading pisces CMD (ret=%d)\n", ret); break; } //printf("Command=%llu, data_len=%d\n", cmd.cmd, cmd.data_len); switch (cmd.cmd) { case ENCLAVE_CMD_ADD_MEM: { struct cmd_mem_add mem_cmd; struct pmem_region rgn; memset(&mem_cmd, 0, sizeof(struct cmd_mem_add)); memset(&rgn, 0, sizeof(struct pmem_region)); ret = read(pisces_fd, &mem_cmd, sizeof(struct cmd_mem_add)); if (ret != sizeof(struct cmd_mem_add)) { printf("Error reading pisces MEM_ADD CMD (ret=%d)\n", ret); send_resp(pisces_fd, -1); break; } rgn.start = mem_cmd.phys_addr; rgn.end = mem_cmd.phys_addr + mem_cmd.size; rgn.type_is_set = 1; rgn.type = PMEM_TYPE_UMEM; rgn.allocated_is_set = 1; rgn.allocated = 0; printf("Adding pmem (%p - %p)\n", (void *)rgn.start, (void *)rgn.end); ret = pmem_add(&rgn); printf("pmem_add returned %d\n", ret); ret = pmem_zero(&rgn); printf("pmem_zero returned %d\n", ret); send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_ADD_CPU: { struct cmd_cpu_add cpu_cmd; int logical_cpu = 0; ret = read(pisces_fd, &cpu_cmd, sizeof(struct cmd_cpu_add)); if (ret != sizeof(struct cmd_cpu_add)) { printf("Error reading pisces CPU_ADD CMD (ret=%d)\n", ret); send_resp(pisces_fd, -1); break; } printf("Adding CPU phys_id %llu, apic_id %llu\n", (unsigned long long) cpu_cmd.phys_cpu_id, (unsigned long long) cpu_cmd.apic_id); logical_cpu = phys_cpu_add(cpu_cmd.phys_cpu_id, cpu_cmd.apic_id); if (logical_cpu == -1) { printf("Error Adding CPU to Kitten\n"); send_resp(pisces_fd, -1); break; } /* Notify Palacios of New CPU */ if (issue_v3_cmd(V3_ADD_CPU, (uintptr_t)logical_cpu) == -1) { printf("Error: Could not add CPU to Palacios\n"); } CPU_SET(logical_cpu, &enclave_cpus); send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_REMOVE_CPU: { struct cmd_cpu_add cpu_cmd; int logical_cpu = 0; ret = read(pisces_fd, &cpu_cmd, sizeof(struct cmd_cpu_add)); if (ret != sizeof(struct cmd_cpu_add)) { printf("Error reading pisces CPU_ADD CMD (ret=%d)\n", ret); send_resp(pisces_fd, -1); break; } printf("Removing CPU phys_id %llu, apic_id %llu\n", (unsigned long long) cpu_cmd.phys_cpu_id, (unsigned long long) cpu_cmd.apic_id); logical_cpu = phys_cpu_remove(cpu_cmd.phys_cpu_id, cpu_cmd.apic_id); if (logical_cpu == -1) { printf("Error remove CPU to Kitten\n"); send_resp(pisces_fd, -1); break; } CPU_CLR(logical_cpu, &enclave_cpus); send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_LAUNCH_JOB: { struct cmd_launch_job * job_cmd = malloc(sizeof(struct cmd_launch_job)); int ret = 0; memset(job_cmd, 0, sizeof(struct cmd_launch_job)); ret = read(pisces_fd, job_cmd, sizeof(struct cmd_launch_job)); if (ret != sizeof(struct cmd_launch_job)) { printf("Error reading Job Launch CMD (ret = %d)\n", ret); free(job_cmd); send_resp(pisces_fd, -1); break; } ret = launch_job(pisces_fd, &(job_cmd->spec)); free(job_cmd); send_resp(pisces_fd, ret); break; } case ENCLAVE_CMD_LOAD_FILE: { struct cmd_load_file * load_cmd = malloc(sizeof(struct cmd_load_file)); int ret = 0; memset(load_cmd, 0, sizeof(struct cmd_load_file)); ret = read(pisces_fd, load_cmd, sizeof(struct cmd_load_file)); if (ret != sizeof(struct cmd_load_file)) { printf("Error reading LOAD FILE CMD (ret = %d)\n", ret); free(load_cmd); send_resp(pisces_fd, -1); break; } ret = load_file(pisces_fd, load_cmd->file_pair.lnx_file, load_cmd->file_pair.lwk_file); free(load_cmd); send_resp(pisces_fd, ret); break; } case ENCLAVE_CMD_STORE_FILE: { break; } case ENCLAVE_CMD_CREATE_VM: { struct pisces_user_file_info * file_info = NULL; struct cmd_create_vm vm_cmd; struct pmem_region rgn; struct v3_guest_img guest_img; id_t my_aspace_id; vaddr_t file_addr; size_t file_size = 0; int path_len = 0; int vm_id = -1; int status = 0; memset(&vm_cmd, 0, sizeof(struct cmd_create_vm)); memset(&rgn, 0, sizeof(struct pmem_region)); memset(&guest_img, 0, sizeof(struct v3_guest_img)); ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_create_vm)); if (ret != sizeof(struct cmd_create_vm)) { send_resp(pisces_fd, -1); printf("Error: CREATE_VM command could not be read\n"); break; } path_len = strlen((char *)vm_cmd.path.file_name) + 1; file_info = malloc(sizeof(struct pisces_user_file_info) + path_len); memset(file_info, 0, sizeof(struct pisces_user_file_info) + path_len); file_info->path_len = path_len; strncpy(file_info->path, (char *)vm_cmd.path.file_name, path_len - 1); file_size = ioctl(pisces_fd, PISCES_STAT_FILE, file_info); status = aspace_get_myid(&my_aspace_id); if (status != 0) return status; if (pmem_alloc_umem(file_size, PAGE_SIZE, &rgn)) { printf("Error: Could not allocate umem for guest image (size=%lu)\n", file_size); break; } pmem_zero(&rgn); status = aspace_map_region_anywhere( my_aspace_id, &file_addr, round_up(file_size, PAGE_SIZE), (VM_USER|VM_READ|VM_WRITE), PAGE_SIZE, "VM Image", rgn.start ); file_info->user_addr = file_addr; ioctl(pisces_fd, PISCES_LOAD_FILE, file_info); guest_img.size = file_size; guest_img.guest_data = (void *)file_info->user_addr; strncpy(guest_img.name, (char *)vm_cmd.path.vm_name, 127); /* Issue VM Create command to Palacios */ vm_id = issue_v3_cmd(V3_CREATE_GUEST, (uintptr_t)&guest_img); aspace_unmap_region(my_aspace_id, file_addr, round_up(file_size, PAGE_SIZE)); pmem_free_umem(&rgn); if (vm_id < 0) { printf("Error: Could not create VM (%s) at (%s) (err=%d)\n", vm_cmd.path.vm_name, vm_cmd.path.file_name, vm_id); send_resp(pisces_fd, vm_id); break; } printf("Created VM (%d)\n", vm_id); send_resp(pisces_fd, vm_id); break; } case ENCLAVE_CMD_FREE_VM: { struct cmd_vm_ctrl vm_cmd; ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_vm_ctrl)); if (ret != sizeof(struct cmd_vm_ctrl)) { send_resp(pisces_fd, -1); break; } /* Signal Palacios to Launch VM */ if (issue_v3_cmd(V3_FREE_GUEST, (uintptr_t)vm_cmd.vm_id) == -1) { send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_ADD_V3_PCI: { struct cmd_add_pci_dev cmd; struct v3_hw_pci_dev v3_pci_spec; int ret = 0; memset(&cmd, 0, sizeof(struct cmd_add_pci_dev)); printf("Adding V3 PCI Device\n"); ret = read(pisces_fd, &cmd, sizeof(struct cmd_add_pci_dev)); if (ret != sizeof(struct cmd_add_pci_dev)) { send_resp(pisces_fd, -1); break; } memcpy(v3_pci_spec.name, cmd.spec.name, 128); v3_pci_spec.bus = cmd.spec.bus; v3_pci_spec.dev = cmd.spec.dev; v3_pci_spec.func = cmd.spec.func; /* Issue Device Add operation to Palacios */ if (issue_v3_cmd(V3_ADD_PCI, (uintptr_t)&(v3_pci_spec)) == -1) { printf("Error: Could not add PCI device to Palacios\n"); send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_FREE_V3_PCI: { struct cmd_add_pci_dev cmd; struct v3_hw_pci_dev v3_pci_spec; int ret = 0; memset(&cmd, 0, sizeof(struct cmd_add_pci_dev)); printf("Removing V3 PCI Device\n"); ret = read(pisces_fd, &cmd, sizeof(struct cmd_add_pci_dev)); if (ret != sizeof(struct cmd_add_pci_dev)) { send_resp(pisces_fd, -1); break; } memcpy(v3_pci_spec.name, cmd.spec.name, 128); v3_pci_spec.bus = cmd.spec.bus; v3_pci_spec.dev = cmd.spec.dev; v3_pci_spec.func = cmd.spec.func; /* Issue Device Add operation to Palacios */ if (issue_v3_cmd(V3_REMOVE_PCI, (uintptr_t)&(v3_pci_spec)) == -1) { printf("Error: Could not remove PCI device from Palacios\n"); send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_LAUNCH_VM: { struct cmd_vm_ctrl vm_cmd; ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_vm_ctrl)); if (ret != sizeof(struct cmd_vm_ctrl)) { send_resp(pisces_fd, -1); break; } /* Signal Palacios to Launch VM */ if (issue_vm_cmd(vm_cmd.vm_id, V3_VM_LAUNCH, (uintptr_t)NULL) == -1) { send_resp(pisces_fd, -1); break; } /* if (xpmem_pisces_add_dom(palacios_fd, vm_cmd.vm_id)) { printf("ERROR: Could not add connect to Palacios VM %d XPMEM channel\n", vm_cmd.vm_id); } */ send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_STOP_VM: { struct cmd_vm_ctrl vm_cmd; ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_vm_ctrl)); if (ret != sizeof(struct cmd_vm_ctrl)) { send_resp(pisces_fd, -1); break; } /* Signal Palacios to Launch VM */ if (issue_vm_cmd(vm_cmd.vm_id, V3_VM_STOP, (uintptr_t)NULL) == -1) { send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_PAUSE_VM: { struct cmd_vm_ctrl vm_cmd; ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_vm_ctrl)); if (ret != sizeof(struct cmd_vm_ctrl)) { send_resp(pisces_fd, -1); break; } /* Signal Palacios to Launch VM */ if (issue_vm_cmd(vm_cmd.vm_id, V3_VM_PAUSE, (uintptr_t)NULL) == -1) { send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_CONTINUE_VM: { struct cmd_vm_ctrl vm_cmd; ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_vm_ctrl)); if (ret != sizeof(struct cmd_vm_ctrl)) { send_resp(pisces_fd, -1); break; } /* Signal Palacios to Launch VM */ if (issue_vm_cmd(vm_cmd.vm_id, V3_VM_CONTINUE, (uintptr_t)NULL) == -1) { send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_VM_CONS_CONNECT: { struct cmd_vm_ctrl vm_cmd; u64 cons_ring_buf = 0; ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_vm_ctrl)); if (ret != sizeof(struct cmd_vm_ctrl)) { printf("Error reading console command\n"); send_resp(pisces_fd, -1); break; } /* Signal Palacios to connect the console */ if (issue_vm_cmd(vm_cmd.vm_id, V3_VM_CONSOLE_CONNECT, (uintptr_t)&cons_ring_buf) == -1) { cons_ring_buf = 0; } printf("Cons Ring Buf=%p\n", (void *)cons_ring_buf); send_resp(pisces_fd, cons_ring_buf); break; } case ENCLAVE_CMD_VM_CONS_DISCONNECT: { struct cmd_vm_ctrl vm_cmd; ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_vm_ctrl)); if (ret != sizeof(struct cmd_vm_ctrl)) { send_resp(pisces_fd, -1); break; } /* Send Disconnect Request to Palacios */ if (issue_vm_cmd(vm_cmd.vm_id, V3_VM_CONSOLE_DISCONNECT, (uintptr_t)NULL) == -1) { send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_VM_CONS_KEYCODE: { struct cmd_vm_cons_keycode vm_cmd; ret = read(pisces_fd, &vm_cmd, sizeof(struct cmd_vm_cons_keycode)); if (ret != sizeof(struct cmd_vm_cons_keycode)) { send_resp(pisces_fd, -1); break; } /* Send Keycode to Palacios */ if (issue_vm_cmd(vm_cmd.vm_id, V3_VM_KEYBOARD_EVENT, vm_cmd.scan_code) == -1) { send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_VM_DBG: { struct cmd_vm_debug pisces_cmd; struct v3_debug_cmd v3_cmd; ret = read(pisces_fd, &pisces_cmd, sizeof(struct cmd_vm_debug)); if (ret != sizeof(struct cmd_vm_debug)) { send_resp(pisces_fd, -1); break; } v3_cmd.core = pisces_cmd.spec.core; v3_cmd.cmd = pisces_cmd.spec.cmd; if (issue_vm_cmd(pisces_cmd.spec.vm_id, V3_VM_DEBUG, (uintptr_t)&v3_cmd) == -1) { send_resp(pisces_fd, -1); break; } send_resp(pisces_fd, 0); break; } case ENCLAVE_CMD_SHUTDOWN: { if (issue_v3_cmd(V3_SHUTDOWN, 0) == -1) { printf("Error: Could not shutdown Palacios VMM\n"); send_resp(pisces_fd, -1); break; } /* Perform additional Cleanup is necessary */ send_resp(pisces_fd, 0); close(pisces_fd); exit(0); } default: { printf("Unknown Pisces Command (%llu)\n", cmd.cmd); send_resp(pisces_fd, -1); break; } } } close(pisces_fd); return 0; }