Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions bin/wfbench
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def get_parser() -> argparse.ArgumentParser:
"(e.g., --output-files {\\\"file1\\\": 1024, \\\"file2\\\": 2048}).")
parser.add_argument("--input-files", help="Input files names as a JSON array "
"(e.g., --input-files [\\\"file3\\\", \\\"file4\\\"]).")
parser.add_argument("--silent", action="store_true", help="Disable all log messages.")
parser.add_argument("--verbose", action="store_true", help="Enable all log messages.")
parser.add_argument("--debug", action="store_true", help="Enable debug log messages.")
parser.add_argument("--with-flowcept", action="store_true", default=False, help="Enable Flowcept monitoring.")
parser.add_argument("--workflow_id", default=None, help="Id to group tasks in a workflow.")
Expand Down Expand Up @@ -387,21 +387,27 @@ def compute_num_chunks(time_limit, cpu_work, gpu_work, num_chunks):
# Compute the (feasible number of chunks)
min_chunk_size_time = 1 # At least 1 second per chunk, if we're doing time-based
# TODO: Pick reasonable factors below so that a chunk takes about min_chunk_size_time sec on a reasonable machine
min_chunk_size_cpu_work = 3000000 * min_chunk_size_time # 1s on my MacBook Pro
min_chunk_size_gpu_work = 30000000 * min_chunk_size_time # unknown.....
min_chunk_size_cpu_work = 2500 * min_chunk_size_time # 1s on Henri's MacBook Pro
min_chunk_size_gpu_work = 2000 * min_chunk_size_time # unknown.....

if time_limit:
num_chunks = min(num_chunks, time_limit // min_chunk_size_time)
else:
if cpu_work:
num_chunks_cpu = min(num_chunks, cpu_work // min_chunk_size_cpu_work)
else:
num_chunks_cpu = 1
num_chunks_cpu = None
if gpu_work:
num_chunks_gpu = min(num_chunks, gpu_work // min_chunk_size_gpu_work)
else:
num_chunks_gpu = 1
num_chunks = min(num_chunks_cpu, num_chunks_gpu)
num_chunks_gpu = None

if num_chunks_cpu is None:
num_chunks = num_chunks_gpu
elif num_chunks_gpu is None:
num_chunks = num_chunks_cpu
else:
num_chunks = min(num_chunks_cpu, num_chunks_gpu)

num_chunks = max(num_chunks, 1) # The above computations may say "zero"
return num_chunks
Expand All @@ -412,7 +418,7 @@ def kill_current_handles(handles: list[ProcessHandle]):
handle.terminate_along_with_children()


def run(workflow_id, name, with_flowcept, silent, debug, rundir, path_lock, path_cores,
def run(workflow_id, name, with_flowcept, verbose, debug, rundir, path_lock, path_cores,
time_limit, cpu_work, percent_cpu, mem, gpu_work, num_chunks,
input_files, output_files):
"""Main function."""
Expand All @@ -423,7 +429,7 @@ def run(workflow_id, name, with_flowcept, silent, debug, rundir, path_lock, path
flowcept = None
flowcept_task = None

if silent:
if verbose:
logging.getLogger().setLevel(logging.NOTSET)
if debug:
logging.getLogger().setLevel(logging.DEBUG)
Expand Down Expand Up @@ -606,6 +612,9 @@ def main():
if not args.time_limit and (not args.cpu_work and not args.gpu_work):
log_error("At least one of --time-limit, --cpu-work, or --gpu-work should be provided.")
sys.exit(1)
if args.time_limit and (not args.cpu_work and not args.gpu_work):
log_error("In addition to --time-limit, at least one of --cpu-work or --gpu-work must be provided (to specify which kind of work should be done).")
sys.exit(1)

run(**vars(args))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ mod.run(
output_files=f'{{"{output_file}": {output_file_size}}}',
input_files=str(input_file).replace("'", '"'),
with_flowcept=bool(workflow_id),
silent=False,
verbose=False,
debug=False,
rundir=None,
path_lock=None,
Expand Down
Loading