Skip to content

Commit

Permalink
removed redundant codes
Browse files Browse the repository at this point in the history
  • Loading branch information
justanhduc committed Nov 4, 2021
1 parent 1ce8b36 commit c57f7d9
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 122 deletions.
35 changes: 0 additions & 35 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ int c_wait_server_commands() {

c_end_of_job(&result);
return result.errorlevel;
} else if (m.type == REMINDER) {
sleep(m.u.gpu_wait_time);
c_send_reminder();
}
}
return -1;
Expand Down Expand Up @@ -774,38 +771,6 @@ void c_show_label() {
return;
}

void c_get_gpu_wait_time() {
struct Msg m;
int res;

m.type = GET_GPU_WAIT_TIME;
send_msg(server_socket, &m);

/* Receive the answer */
res = recv_msg(server_socket, &m);
if (res != sizeof(m))
error("Error in get_gpu_wait_time");

if (m.type == GET_GPU_WAIT_TIME)
printf("%d\n", m.u.gpu_wait_time);
else
warning("Wrong internal message in get_gpu_wait_time");
}

void c_set_gpu_wait_time() {
struct Msg m;

m.type = SET_GPU_WAIT_TIME;
m.u.gpu_wait_time = command_line.gpu_wait_time;
send_msg(server_socket, &m);
}

void c_send_reminder() {
struct Msg m;
m.type = REMINDER;
send_msg(server_socket, &m);
}

void c_show_cmd() {
struct Msg m;
int res;
Expand Down
18 changes: 0 additions & 18 deletions jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

#include "main.h"

int time_between_gpu_runs = 5;
int *used_gpus;
int num_total_gpus;
static int sent_reminder = 0;

/* The list will access them */
int busy_slots = 0;
Expand Down Expand Up @@ -688,14 +686,9 @@ int next_run_job() {
/* some GPUs might already be claimed by other jobs, but the system still reports as free -> skip */
if (i < p->num_gpus) {
free(freeGpuList);
if (!sent_reminder) {
s_request_reminder_after(time_between_gpu_runs, p->jobid);
sent_reminder = 1;
}
p = p->next;
continue;
}
sent_reminder = 0;
free(freeGpuList);
}

Expand Down Expand Up @@ -1509,17 +1502,6 @@ void s_send_state(int s, int jobid) {
send_state(s, p->state);
}

void s_set_time_between_gpu_runs(int seconds) {
time_between_gpu_runs = seconds;
}

void s_send_time_between_gpu_runs(int s) {
struct Msg m;

m.type = GET_GPU_WAIT_TIME;
m.u.gpu_wait_time = time_between_gpu_runs;
send_msg(s, &m);
}

static void dump_job_struct(FILE *out, const struct Job *p) {
fprintf(out, " new_job\n");
Expand Down
25 changes: 0 additions & 25 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ static struct option longOptions[] = {
{"last_queue_id", no_argument, NULL, 'q'},
{"gpus", required_argument, NULL, 'G'},
{"gpu_indices", required_argument, NULL, 'g'},
{"set_gpu_wait", required_argument, NULL, 0},
{"get_gpu_wait", no_argument, NULL, 0},
{"full_cmd", optional_argument, NULL, 'F'},
{NULL, 0, NULL, 0}
};
Expand All @@ -116,19 +114,6 @@ void parse_opts(int argc, char **argv) {
break;

switch (c) {
case 0:
if (strcmp(longOptions[optionIdx].name, "set_gpu_wait") == 0) {
command_line.request = c_SET_GPU_WAIT_TIME;
command_line.gpu_wait_time = atoi(optarg);
if (command_line.gpu_wait_time < 0)
error("Cannot set negative value for gpu_wait_time");
break;
} else if (strcmp(longOptions[optionIdx].name, "get_gpu_wait") == 0) {
command_line.request = c_GET_GPU_WAIT_TIME;
break;
} else
error("Wrong option %s.", longOptions[optionIdx].name);
break;
case 'K':
command_line.request = c_KILL_SERVER;
command_line.should_go_background = 0;
Expand Down Expand Up @@ -637,16 +622,6 @@ int main(int argc, char **argv) {
/* This will also print the state into stdout */
c_get_state();
break;
case c_SET_GPU_WAIT_TIME:
if (!command_line.need_server)
error("The command %i needs the server", command_line.request);
c_set_gpu_wait_time();
break;
case c_GET_GPU_WAIT_TIME:
if (!command_line.need_server)
error("The command %i needs the server", command_line.request);
c_get_gpu_wait_time();
break;
}

if (command_line.need_server) {
Expand Down
16 changes: 0 additions & 16 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ enum MsgTypes {
GET_LABEL,
LAST_ID,
KILL_ALL,
SET_GPU_WAIT_TIME,
GET_GPU_WAIT_TIME,
REMINDER,
GET_CMD
};

Expand Down Expand Up @@ -77,8 +74,6 @@ enum Request {
c_GET_LABEL,
c_LAST_ID,
c_KILL_ALL,
c_SET_GPU_WAIT_TIME,
c_GET_GPU_WAIT_TIME,
c_SHOW_CMD
};

Expand Down Expand Up @@ -281,12 +276,6 @@ void c_show_label();

void c_kill_all_jobs();

void c_set_gpu_wait_time();

void c_get_gpu_wait_time();

void c_send_reminder();

void c_show_cmd();

/* jobs.c */
Expand Down Expand Up @@ -354,17 +343,12 @@ void s_send_label(int s, int jobid);

void s_kill_all_jobs(int s);

void s_set_time_between_gpu_runs(int seconds);

void s_send_time_between_gpu_runs(int s);

/* server.c */
void server_main(int notify_fd, char *_path);

void dump_conns_struct(FILE *out);

void s_request_reminder_after(int time, int jobid);

void s_send_cmd(int s, int jobid);

/* server_start.c */
Expand Down
8 changes: 0 additions & 8 deletions msgdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ void msgdump(FILE *f, const struct Msg *m)
fprintf(f, " Outputsize: %i\n", m->u.output.ofilename_size);
fprintf(f, " PID: %i\n", m->u.output.pid);
break;
case GET_GPU_WAIT_TIME:
fprintf(f, "GET_GPU_WAIT_TIME\n");
fprintf(f, "Time: %d\n", m->u.gpu_wait_time);
break;
case SET_GPU_WAIT_TIME:
fprintf(f, "SET_GPU_WAIT_TIME\n");
fprintf(f, "Time: %d\n", m->u.gpu_wait_time);
break;
case GET_LABEL:
fprintf(f, "GET_LABEL\n");
fprintf(f, " Jobid: %i\n", m->u.jobid);
Expand Down
20 changes: 0 additions & 20 deletions server.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,6 @@ client_read(int index) {
case GET_STATE:
s_send_state(s, m.u.jobid);
break;
case SET_GPU_WAIT_TIME:
s_set_time_between_gpu_runs(m.u.gpu_wait_time);
break;
case GET_GPU_WAIT_TIME:
s_send_time_between_gpu_runs(s);
break;
case REMINDER:
break;
case GET_VERSION:
s_send_version(s);
break;
Expand Down Expand Up @@ -542,18 +534,6 @@ static void s_newjob_nok(int index) {
send_msg(s, &m);
}

void s_request_reminder_after(int time, int jobid) {
struct Msg m;
int idx;

m.type = REMINDER;
m.u.gpu_wait_time = time;
idx = get_conn_of_jobid(jobid);
if (idx == -1)
error("Cannot find the client holding job %d", jobid);
send_msg(client_cs[idx].socket, &m);
}

static void dump_conn_struct(FILE *out, const struct Client_conn *p) {
fprintf(out, " new_conn\n");
fprintf(out, " socket %i\n", p->socket);
Expand Down

0 comments on commit c57f7d9

Please sign in to comment.