-
Notifications
You must be signed in to change notification settings - Fork 919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REVIEW] Implement type_dispatcher #379
[REVIEW] Implement type_dispatcher #379
Conversation
…unctor to return void. void() is valid whereas void{} is not valid.
…it tests for get_column_byte_width.
…declarations." This reverts commit a32f087.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. A bunch of minor comments. One concern about testing.
Co-Authored-By: jrhemstad <[email protected]>
Co-Authored-By: jrhemstad <[email protected]>
This is the next PR I would like to merge, because other PRs (I count at least 3 currently) can then be updated to use its functionality. @jrhemstad, is it ready once the conflicts are resolved? |
Can one of the admins verify this patch? |
add to whitelist |
Removed the documentation from each wrapper struct in favor of static member with the corresponding wrapped gdf_dtype.
…Make config to use C++14 standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are independent of the type_dispatcher, and I suggest they be merged separately to prevent confusion / for orderliness' sake.
@eyalroz not sure what changes you're referring to, but there's still some issues I'm ironing out with the submodules after merging in master after the refactor. |
I was sure I saw changes in Rename libgdf namespace to cudf which were in |
@harrism conflicts are resolved and this is ready for final review/merge. |
Jake removed the pragma but forgot to remove comment.
Congratulations @jrhemstad for a well-deserved merge :-) |
The purpose of this new function is to alleviate some of the pain of having to reconstruct the type of the type-erased data buffer from a gdf_column.
In more detail, the problem is that a gdf_column is type-erased, i.e., in the struct:
struct gdf_column{
void* data;
gdf_dtype dtype;
}
Where data points to a contiguous data buffer on the device, and the gdf_dtype enum tells us what type is actually contained in the buffer.
This requires a great deal of code of the form:
switch(gdf_column.dtype)
{
case GDF_INT: // cast gdf_column.data to int
case GDF_DOUBLE: // cast gdf_column.data to double
case GDF_FLOAT: // cast gdf_column.data to float
... 15 and counting total cases
}
Currently this particular switch logic is repeated all over the source of libgdf. Apart from being an eye-sore, it is also a nightmare for maintainability. Any time a new type is added (or removed), then a great deal of source code will need to be changed, which is prone to introduce bugs.
The new
gdf_type_dispatcher
function will centralize thisswitch
logic to exactly one place. This will be a boon to both maintainability as well as code readability.This PR introduces the
gdf_type_dispatcher
as well as updates some of the existing code to make use of this function, including:get_column_byte_width
gdf_table::copy_row
gdf_table::hash_row
gdf_table::rows_equal
.It is not the goal of this PR to update all of the code-base to use the
gdf_type_dispatcher
, but rather to introduce it and show how it may be used.This PR also updates the C++ standard used to C++14. This is required for the automatic return type deduction of the
gdf_type_dispatcher
.