diff --git a/pyopencl/algorithm.py b/pyopencl/algorithm.py index 40c6a81467afc372ab49b29d97348c18392a13d3..302c0a7901932768a1cc2b8242a2138b69856ea7 100644 --- a/pyopencl/algorithm.py +++ b/pyopencl/algorithm.py @@ -1026,7 +1026,17 @@ class ListOfListsBuilder: This implies that all lists are contiguous. - *event* is a :class:`pyopencl.Event` for dependency management. + If eliminate_empty_output_lists is set to True, *lists* has two + additional attributes ``num_nonempty_lists`` and ``indices`` + + * ``num_nonempty_lists`` for the number of nonempty lists. + * ``indices`` for the index of nonempty list in input objects. + + In this case, `starts` has `num_nonempty_lists` + 1 entries. The *i*'s + entry is the start of the *i*'th nonempty list, which is generated by + the object with index *indices[i]*. + + *event* is a :class:`pyopencl.Event` for dependency management. .. versionchanged:: 2016.2 @@ -1096,9 +1106,12 @@ class ListOfListsBuilder: **dict(wait_for=wait_for)) if self.eliminate_empty_output_lists: + compress_events = {} for name, dtype in self.list_names_and_dtypes: if name in omit_lists: continue + if name in self.count_sharing: + continue info_record = result[name] info_record.indices = cl.array.empty( @@ -1108,7 +1121,7 @@ class ListOfListsBuilder: info_record.mask_scan = cl.array.empty( queue, (n_objects + 1,), index_dtype, allocator=allocator) info_record.mask_scan[0] = 0 - info_record.compress_events = compress_kernel( + compress_events[name] = compress_kernel( info_record.starts, info_record.indices, info_record.mask_scan, @@ -1127,7 +1140,7 @@ class ListOfListsBuilder: info_record = result[name] if self.eliminate_empty_output_lists: - info_record.compress_events.wait() + compress_events[name].wait() num_nonempty_lists = info_record.num_nonempty_lists.get()[0] info_record.num_nonempty_lists = num_nonempty_lists info_record.starts = info_record.starts[:num_nonempty_lists + 1]