def _aio_handle_tasklet(pool_params): args, tid, read_op = pool_params # Create schedule schedule = get_schedule(args, read_op) task_log(tid, f'schedule = {schedule}') task_barrier(aio_barrier, args.threads) # Run pre task task_log(tid, f'running pre-task') ctxt = schedule["pre"]((args, tid)) task_barrier(aio_barrier, args.threads) # Run main tasks in a loop ctxt["main_task_sec"] = 0 for i in range(args.loops): task_log(tid, f'running main task {i}') start_time = time.time() ctxt = schedule["main"]((args, tid, ctxt)) task_barrier(aio_barrier, args.threads) stop_time = time.time() ctxt["main_task_sec"] += stop_time - start_time # Run post task task_log(tid, f'running post-task') ctxt = schedule["post"]((args, tid, ctxt)) task_barrier(aio_barrier, args.threads) return ctxt["main_task_sec"], ctxt[ "elapsed_sec"], ctxt["num_bytes"] * args.loops
def pre_basic(args, tid, read_op): io_string = "Read" if read_op else "Write" num_bytes = os.path.getsize(args.read_file) if read_op else args.write_size file = args.read_file if read_op else f'{args.write_file}.{tid}' task_log(tid, f'Allocate tensor of size {num_bytes} bytes') buffer = torch.empty(num_bytes, dtype=torch.uint8, device='cpu').pin_memory() task_log( tid, f'{io_string} file {file} of size {num_bytes} bytes from buffer on device {buffer.device}' ) ctxt = {} ctxt['file'] = file ctxt['num_bytes'] = num_bytes ctxt['buffer'] = buffer ctxt['elapsed_sec'] = 0 return ctxt
def pre_handle(args, tid, read_op): io_string = "Read" if read_op else "Write" num_bytes = os.path.getsize(args.read_file) if read_op else args.write_size file = args.read_file if read_op else f'{args.write_file}.{tid}' task_log(tid, f'Allocate tensor of size {num_bytes} bytes') if args.gpu: buffer = torch.empty(num_bytes, dtype=torch.uint8, device='cuda') else: buffer = torch.empty(num_bytes, dtype=torch.uint8, device='cpu').pin_memory() task_log( tid, f'{io_string} file {file} of size {num_bytes} bytes from buffer on device {buffer.device}' ) io_parallel = args.io_parallel if args.io_parallel else 1 handle = AsyncIOBuilder().load().aio_handle(args.block_size, args.queue_depth, args.single_submit, args.overlap_events, io_parallel) task_log(tid, f'created deepspeed aio handle') ctxt = {} ctxt['file'] = file ctxt['num_bytes'] = num_bytes ctxt['handle'] = handle ctxt['buffer'] = buffer ctxt['elapsed_sec'] = 0 return ctxt