|
| 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_OPS_HPP |
| 18 | +#define BITMASK_OPS_HPP |
| 19 | + |
| 20 | +#include <types.hpp> |
| 21 | +#include <cuda_runtime.h> |
| 22 | + |
| 23 | +#include <rmm/thrust_rmm_allocator.h> |
| 24 | + |
| 25 | +/**---------------------------------------------------------------------------* |
| 26 | + * @file bitmask_ops.hpp |
| 27 | + * @brief Internal functions for bitmask operations. |
| 28 | +*---------------------------------------------------------------------------**/ |
| 29 | + |
| 30 | +/**---------------------------------------------------------------------------* |
| 31 | + * @brief Sets all bits in input valid mask to 1 |
| 32 | + * |
| 33 | + * @param valid_out preallocated output valid mask |
| 34 | + * @param out_null_count number of nulls (0 bits) in valid mask. Always set to 0 |
| 35 | + * @param num_values number of values in column associated with output mask |
| 36 | + * @param stream cuda stream to run in |
| 37 | + * @return gdf_error |
| 38 | + *---------------------------------------------------------------------------**/ |
| 39 | +gdf_error all_bitmask_on(gdf_valid_type* valid_out, |
| 40 | + gdf_size_type& out_null_count, |
| 41 | + gdf_size_type num_values, cudaStream_t stream); |
| 42 | + |
| 43 | +/**---------------------------------------------------------------------------* |
| 44 | + * @brief Computes bitwise AND on two valid masks and sets it in output |
| 45 | + * |
| 46 | + * @param out_null_count number of nulls (0 bits) in output valid mask |
| 47 | + * @param valid_out preallocated mask to set the result values in |
| 48 | + * @param valid_left input valid mask 1 |
| 49 | + * @param valid_right input valid mask 2 |
| 50 | + * @param stream cuda stream to run in |
| 51 | + * @param num_values number of values in each input mask valid_left and |
| 52 | + * valid_right |
| 53 | + * @return gdf_error |
| 54 | + *---------------------------------------------------------------------------**/ |
| 55 | +gdf_error apply_bitmask_to_bitmask(gdf_size_type& out_null_count, |
| 56 | + gdf_valid_type* valid_out, |
| 57 | + gdf_valid_type* valid_left, |
| 58 | + gdf_valid_type* valid_right, |
| 59 | + cudaStream_t stream, |
| 60 | + gdf_size_type num_values); |
| 61 | + |
| 62 | + |
| 63 | +namespace cudf { |
| 64 | + |
| 65 | +/**---------------------------------------------------------------------------* |
| 66 | + * @brief Computes a bitmask indicating the presence of NULL values in rows of a |
| 67 | + * table. |
| 68 | + * |
| 69 | + * If a row `i` in `table` contains one or more NULL values, then bit `i` in the |
| 70 | + * returned bitmask will be 0. |
| 71 | + * |
| 72 | + * Otherwise, bit `i` will be 1. |
| 73 | + * |
| 74 | + * @param table The table to compute the row bitmask of. |
| 75 | + * @return bit_mask::bit_mask_t* The bitmask indicating the presence of NULLs in |
| 76 | + * a row |
| 77 | + *---------------------------------------------------------------------------**/ |
| 78 | +rmm::device_vector<bit_mask::bit_mask_t> row_bitmask(cudf::table const& table, |
| 79 | + cudaStream_t stream = 0); |
| 80 | +} // namespace cudf |
| 81 | + |
| 82 | +#endif |
0 commit comments