|
| 1 | +/* |
| 2 | + * Copyright (c) 2019, NVIDIA CORPORATION. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +#ifndef BITMASK_HPP |
| 18 | +#define BITMASK_HPP |
| 19 | + |
| 20 | +#include <cudf.h> |
| 21 | +#include <types.hpp> |
| 22 | + |
| 23 | +/** |
| 24 | + * @brief Counts the number of valid bits for the specified number of rows |
| 25 | + * in a validity bitmask. |
| 26 | + * |
| 27 | + * If the bitmask is null, returns a count equal to the number of rows. |
| 28 | + * |
| 29 | + * @param[in] masks The validity bitmask buffer in device memory |
| 30 | + * @param[in] num_rows The number of bits to count |
| 31 | + * @param[out] count The number of valid bits in the buffer from [0, num_rows) |
| 32 | + * |
| 33 | + * @returns GDF_SUCCESS upon successful completion |
| 34 | + * |
| 35 | + */ |
| 36 | +gdf_error gdf_count_nonzero_mask(gdf_valid_type const* masks, |
| 37 | + gdf_size_type num_rows, gdf_size_type* count); |
| 38 | + |
| 39 | +/** ---------------------------------------------------------------------------* |
| 40 | + * @brief Concatenate the validity bitmasks of multiple columns |
| 41 | + * |
| 42 | + * Accounts for the differences between lengths of columns and their bitmasks |
| 43 | + * (e.g. because gdf_valid_type is larger than one bit). |
| 44 | + * |
| 45 | + * @param[out] output_mask The concatenated mask |
| 46 | + * @param[in] output_column_length The total length (in data elements) of the |
| 47 | + * concatenated column |
| 48 | + * @param[in] masks_to_concat The array of device pointers to validity bitmasks |
| 49 | + * for the columns to concatenate |
| 50 | + * @param[in] column_lengths An array of lengths of the columns to concatenate |
| 51 | + * @param[in] num_columns The number of columns to concatenate |
| 52 | + * @return gdf_error GDF_SUCCESS or GDF_CUDA_ERROR if there is a runtime CUDA |
| 53 | + error |
| 54 | + * |
| 55 | + ---------------------------------------------------------------------------**/ |
| 56 | +gdf_error gdf_mask_concat(gdf_valid_type* output_mask, |
| 57 | + gdf_size_type output_column_length, |
| 58 | + gdf_valid_type* masks_to_concat[], |
| 59 | + gdf_size_type* column_lengths, |
| 60 | + gdf_size_type num_columns); |
| 61 | + |
| 62 | + |
| 63 | +#endif |
0 commit comments