package hack_parallel
Parallel and shared memory library
Install
Dune Dependency
Authors
Maintainers
Sources
1.0.1.tar.gz
md5=ba7c72bc207e326b72e294fc76f6ad2c
sha512=5020d47f97bea2f88e2a40411894d03232a7f2282606926c93c7d4c96d72e94a966be852897a9b16f7e0893ba376512045abb9d93020a7c03c3def4f3d918f8e
doc/src/hack_parallel.procs/hack_bucket.ml.html
Source file hack_bucket.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
(** * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the "hack" directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * *) (****************************************************************************) (* Moduling Making buckets. * When we parallelize, we need to create "buckets" of tasks for the * workers. * Given a list of files, we want to split it up into buckets such that * every worker is busy long enough. If the bucket is too big, it hurts * load balancing, if it is too small, the overhead in synchronization time * hurts *) (****************************************************************************) type 'a bucket = | Job of 'a | Wait | Done type 'a next = unit -> 'a bucket let make_ bucket_size jobs = let i = ref 0 in fun () -> let bucket_size = min (Array.length jobs - !i) bucket_size in let result = Array.sub jobs !i bucket_size in i := bucket_size + !i; Array.to_list result let make_list ~num_workers jobs = let jobs = Array.of_list jobs in let bucket_size = max 1 (1 + ((Array.length jobs) / num_workers)) in make_ bucket_size jobs let of_list = function | [] -> Done | wl -> Job wl let make ~num_workers jobs = let maker = make_list ~num_workers jobs in fun () -> of_list (maker ()) type 'a of_n = { work: 'a; bucket: int; total: int } let make_n_buckets ~buckets ~split = let next_bucket = ref 0 in fun () -> let current = !next_bucket in incr next_bucket; if (current < buckets) then Job { work = split ~bucket:current; bucket = current; total = buckets } else Done
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>