Skip to content

Commit

Permalink
Merge pull request #1389 from eyalroz/fix-issue-1368
Browse files Browse the repository at this point in the history
[REVIEW] refactored set_null_count()
  • Loading branch information
harrism authored Apr 13, 2019
2 parents ea880d0 + 84c3d5b commit f6ad6de
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- PR #1319 CSV Reader: Use column wrapper for gdf_column output alloc/dealloc
- PR #1376 Change series quantile default to linear
- PR #1399 Replace CFFI bindings for NVTX functions with Cython bindings
- PR #1389 Refactored `set_null_count()`
- PR #1386 Added macros `GDF_TRY()`, `CUDF_TRY()` and `ASSERT_CUDF_SUCCEEDED()`

## Bug Fixes
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/copying/gather.cu
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ struct column_gatherer {
gather_map, check_bounds, stream);

// TODO compute the null count in the gather_bitmask kernels
gdf_error gdf_status = set_null_count(destination_column);
CUDF_EXPECTS(GDF_SUCCESS == gdf_status, "set_null_count failed");
set_null_count(*destination_column);
}

CHECK_STREAM(stream);
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/copying/scatter.cu
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ struct column_scatterer {
scatter_map);

// Update destination column's null count
gdf_error gdf_status = set_null_count(destination_column);
CUDF_EXPECTS(GDF_SUCCESS == gdf_status, "set_null_count failed");
set_null_count(*destination_column);
}

CHECK_STREAM(stream);
Expand Down
24 changes: 14 additions & 10 deletions cpp/src/utilities/cudf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <cuda_runtime_api.h>

#include <vector>
#include <cassert>

#ifdef __CUDACC__
#define CUDA_HOST_DEVICE_CALLABLE __host__ __device__ inline
Expand All @@ -18,16 +19,19 @@
#define CUDA_LAUNCHABLE
#endif

inline gdf_error set_null_count(gdf_column* col) {
gdf_size_type valid_count{};
gdf_error result =
gdf_count_nonzero_mask(col->valid, col->size, &valid_count);

GDF_REQUIRE(GDF_SUCCESS == result, result);

col->null_count = col->size - valid_count;

return GDF_SUCCESS;
/**---------------------------------------------------------------------------*
* @brief Sets a @ref gdf_column 's (uninitialized) null_count value by
* counting the zeros in its validity indicator bits (if it has them).
**---------------------------------------------------------------------------*/
inline void set_null_count(gdf_column& column) {
if (column.valid == nullptr) {
column.null_count = 0;
}
else {
gdf_size_type valid_count;
CUDF_TRY(gdf_count_nonzero_mask(column.valid, column.size, &valid_count));
column.null_count = column.size - valid_count;
}
}

/* --------------------------------------------------------------------------*/
Expand Down
6 changes: 1 addition & 5 deletions cpp/tests/utilities/column_wrapper.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,7 @@ struct column_wrapper {
the_column.valid = nullptr;
}

gdf_error result = set_null_count(&the_column);
if (GDF_SUCCESS != result) {
throw std::runtime_error("Failed to set null count. Error code: " +
std::to_string(result));
}
set_null_count(the_column);
}

rmm::device_vector<ColumnType> data; ///< Container for the column's data
Expand Down

0 comments on commit f6ad6de

Please sign in to comment.