From dde0298fe75e0a5f017a88d03d6934fa6131385f Mon Sep 17 00:00:00 2001 From: Duc Nguyen Date: Thu, 12 Nov 2020 23:42:32 +0900 Subject: [PATCH] updated readme. added useful scripts --- CMakeLists.txt | 40 +++++++++++++++++++++++++++++ Makefile | 68 -------------------------------------------------- README.md | 66 ++++++++++++++++++++++++++++++++++++++++-------- install | 7 ++++++ uninstall | 5 ++++ 5 files changed, 107 insertions(+), 79 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile create mode 100755 install create mode 100755 uninstall diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..0b0d6ef --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.5) +project(Task-Spooler C) + +set(CMAKE_C_STANDARD 11) + +set(CMAKE_CUDA_COMPILER $ENV{CUDA_HOME}/bin/nvcc) +find_package(CUDA REQUIRED) +include_directories($ENV{CUDA_HOME}/include) + +add_executable( + ts + client.c + env.c + error.c + execute.c + gpu.c + info.c + jobs.c + list.c + mail.c + main.c + msg.c + msgdump.c + print.c + server.c + server_start.c + signals.c + tail.c +) + +target_link_libraries(ts ${CUDA_LIBRARIES}) + +set( + TS_PERMISSIONS + OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE +) + +install(TARGETS ts DESTINATION /usr/local/bin) diff --git a/Makefile b/Makefile deleted file mode 100644 index d8fc416..0000000 --- a/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -PREFIX?=/usr/local -GLIBCFLAGS=-D_XOPEN_SOURCE=500 -D__STRICT_ANSI__ -CPPFLAGS+=$(GLIBCFLAGS) -CFLAGS?=-pedantic -ansi -Wall -g -O0 -std=c11 -OBJECTS=main.o \ - server.o \ - server_start.o \ - client.o \ - msgdump.o \ - jobs.o \ - execute.o \ - msg.o \ - mail.o \ - error.o \ - signals.o \ - list.o \ - print.o \ - info.o \ - env.o \ - tail.o\ - gpu.o -INSTALL=install -c - -all: ts - -tsretry: tsretry.c - -ts: $(OBJECTS) - $(CC) $(LDFLAGS) -o ts $^ -L$(CUDA_HOME)/lib64 -I$(CUDA_HOME)/include -lpthread -lcudart -lcublas -fopenmp - -# Test our 'tail' implementation. -ttail: tail.o ttail.o - $(CC) $(LDFLAGS) -o ttail $^ - - -.c.o: - $(CC) $(CFLAGS) $(CPPFLAGS) -c $< - -# Dependencies -main.o: main.c main.h -server_start.o: server_start.c main.h -server.o: server.c main.h -client.o: client.c main.h -msgdump.o: msgdump.c main.h -jobs.o: jobs.c main.h -execute.o: execute.c main.h -msg.o: msg.c main.h -mail.o: mail.c main.h -error.o: error.c main.h -signals.o: signals.c main.h -list.o: list.c main.h -tail.o: tail.c main.h -ttail.o: ttail.c main.h -gpu.o: gpu.c main.h - $(CC) $(CFLAGS) $(CPPFLAGS) -L$(CUDA_HOME)/lib64 -I$(CUDA_HOME)/include -lpthread -lcudart -lcublas -fopenmp -c -std=c11 gpu.c - -clean: - rm -f *.o ts - -install: ts - $(INSTALL) -d $(PREFIX)/bin - $(INSTALL) ts $(PREFIX)/bin - $(INSTALL) -d $(PREFIX)/share/man/man1 - $(INSTALL) -m 644 ts.1 $(PREFIX)/share/man/man1 - -uninstall: - rm -f $(PREFIX)/bin/ts - rm -f $(PREFIX)/share/man/man1/ts.1 diff --git a/README.md b/README.md index 9ba6db1..131642f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,19 @@ For your first contact, you can read an article at linux.com, which I like as overview, guide and examples (original url). On more advanced usage, don't neglect the TRICKS file in the package. +### Changelog +**Major update (Nov 11, 2020)** + +- Added GPU support. A GPU job can run or not depending on the number of available GPUs as well as +free slots. +- Various functionality updates + + - Dependent jobs will run no matter what the error codes of their parents are. + - Adding more query information about a job. + - Added long options. + +- Replaced Makefile by CMake. + ## Features I wrote Task Spooler because I didn't have any comfortable way of running batch jobs in my linux computer. I wanted to: @@ -39,6 +52,24 @@ At the end, after some time using and developing ts, it can do something more: You can look at an old (but representative) screenshot of ts-0.2.1 if you want. +## Setup + +### Install Task Spooler + +To setup Task Spooler with GPU support, one needs to set a `CUDA_HOME` environment variable. +Then, simple run the provided script + +``` +./install +``` + +### Uinstall Task Spooler + +``` +./uninstall +``` +Why would you want to do that anyway? + ## Mailing list I created a GoogleGroup for the program. You look for the archive and the join methods in the taskspooler google group page. @@ -76,45 +107,58 @@ Eric Keller wrote a nodejs web server showing the status of the task spooler que ## Manual -Look at its manpage (v0.6.1). Here you also have a copy of the help for the same version: +**NOTE**: `man ts` is not updated (yet). ``` -usage: ./ts [action] [-ngfmd] [-L ] [cmd...] +usage: ts [action] [-ngfmdE] [-L ] [-D ] [cmd...] Env vars: TS_SOCKET the path to the unix socket used by the ts command. TS_MAILTO where to mail the result (on -m). Local user by default. TS_MAXFINISHED maximum finished jobs in the queue. + TS_MAXCONN maximum number of ts connections at once. TS_ONFINISH binary called on job end (passes jobid, error, outfile, command). TS_ENV command called on enqueue. Its output determines the job information. TS_SAVELIST filename which will store the list, if the server dies. TS_SLOTS amount of jobs which can run at once, read on server start. + TMPDIR directory where to place the output files and the default socket. +Long option actions: + --set_gpu_wait set time to wait before running the next GPU job (30 seconds by default). + --get_gpu_wait get time to wait before running the next GPU job. + --get_label || -a [id] show the job label. Of the last added, if not specified. + --count_running || -R return the number of running jobs + --last_queue_id || -q show the job ID of the last added. +Long option adding jobs: + --gpus || -G [num] number of GPUs required by the job (1 default). Actions: - -K kill the task spooler server. - -C clear the list of finished jobs. - -l show the job list (default action). - -R number of running jobs. - -S [num] set the number of max simultanious jobs of the server. - -t [id] tail -f the output of the job. Last run if not specified. - -c [id] cat the output of the job. Last run if not specified. + -K kill the task spooler server + -C clear the list of finished jobs + -l show the job list (default action) + -S [num] get/set the number of max simultaneous jobs of the server. + -t [id] \"tail -n 10 -f\" the output of the job. Last run if not specified. + -c [id] like -t, but shows all the lines. Last run if not specified. -p [id] show the pid of the job. Last run if not specified. -o [id] show the output file. Of last job run, if not specified. -i [id] show job information. Of last job run, if not specified. - -a [id] show job label. Of last job run, if not specified. -s [id] show the job state. Of the last added, if not specified. -r [id] remove a job. The last added, if not specified. -w [id] wait for a job. The last added, if not specified. + -k [id] send SIGTERM to the job process group. The last run, if not specified. + -T send SIGTERM to all running job groups. -u [id] put that job first. The last added, if not specified. -U swap two jobs in the queue. + -B in case of full queue on the server, quit (2) instead of waiting. -h show this help -V show the program version Options adding jobs: -n don't store the output of the command. + -E Keep stderr apart, in a name like the output file, but adding '.e'. -g gzip the stored output (if not -n). -f don't fork into background. -m send the output by e-mail (uses sendmail). -d the job will be run after the last job ends. - -D [id] the job will be run after the job with id ends. + -D the job will be run after the job of given id ends. -L name this task with a label, to be distinguished on listing. + -N number of slots required by the job (1 default). ``` ## Thanks diff --git a/install b/install new file mode 100755 index 0000000..7e50374 --- /dev/null +++ b/install @@ -0,0 +1,7 @@ +#!/bin/bash + +mkdir build && cd build || exit +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j 3 +sudo make install +sudo install -c -m 644 ../ts.1 /usr/local/share/man/man1 diff --git a/uninstall b/uninstall new file mode 100755 index 0000000..74e23c1 --- /dev/null +++ b/uninstall @@ -0,0 +1,5 @@ +#!/bin/bash + +ts -K +sudo rm -f /usr/local/bin/ts +sudo rm -f /usr/local/share/man/man1/ts.1