Skip to content

[REVIEW] Move CFFI to Cython - #132

Closed
kkraus14 wants to merge 8 commits into
rapidsai:branch-0.10from
kkraus14:fea-rmm-cython
Closed

kkraus14 wants to merge 8 commits into
rapidsai:branch-0.10from
kkraus14:fea-rmm-cython

Conversation

@kkraus14

@kkraus14 kkraus14 commented Sep 20, 2019 •

Copy link
Copy Markdown
Contributor

Fixes #40

@kkraus14 kkraus14 added 2 - In Progress Currently a work in progress Python Related to RMM Python API labels Sep 20, 2019
@kkraus14 kkraus14 self-assigned this Sep 20, 2019
Comment thread python/rmm/_lib/lib.pyx Outdated
# See cpp/src/utilities/cuda_utils.cu
# cudaerr = self._api.gdf_cuda_last_error()
# errname = self._ffi_str(self._api.gdf_cuda_error_name(cudaerr))
# details = self._ffi_str(self._api.gdf_cuda_error_string(cudaerr))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This abused CFFI for a circular dependency on libcudf, need to decide what we want to do here...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harrism could use your guidance here on what we should do for error checking the functions for now. It looks like we were checking for libgdf error codes within RMM here which feels... wrong?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we were checking CUDA error codes using cudf's gdf_cuda_error_*() functions. All those do is pass through to CUDA APIs. I think when we switch to exceptions the error codes go away in RMM, and it will throw exceptions with useful messages anyway. So this whole function can go away then, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right that was a silly dependency on cuDF.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connected with @harrism on a call to discuss and the plan of action is to merge #38 into this PR, and then remove all of the error code checking since we'll be throwing exceptions. We can move from the C APIs to the C++ APIs in the future follow up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jrhemstad if you have any thoughts on this since #38 has been sitting on deck for quite a bit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connected with @jrhemstad and he said #38 isn't feasible for 0.10, so just moved to using the built-in RMM functions for handling RMM error codes and we can rip that out in the future when we enable exceptions.

Comment thread python/setup.py Resolved

@shwina shwina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kkraus14 kkraus14 added 3 - Ready for review Ready for review by team and removed 2 - In Progress Currently a work in progress labels Sep 27, 2019
@kkraus14 kkraus14 changed the title [WIP] Move CFFI to Cython [REVIEW] Move CFFI to Cython Sep 27, 2019

@dantegd dantegd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some very small questions, besides that it looks good!

Comment thread python/rmm/_lib/lib.pyx
frame = inspect.currentframe().f_back
while frame:
filename = inspect.getfile(frame)
# May need to tweak this to handle Cython

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a github issue to look into this further?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I just saw that we check for rmm.py and didn't want to dive further in for this initial move.

Comment thread python/rmm/rmm.py
return out_dev_array, False
else:
if isinstance(obj, np.void):
# raise NotImplementedError("DeviceRecord type not supported "

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be leftover commented code that needs to be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, I only tried to touch what was necessary to touch and this was a function that only used the Python API which didn't change so I didn't touch it.

Comment thread python/rmm/rmm_cfg.py
Usage example:
from librmm_cffi import librmm_config as rmm_cfg
rmm_cf.use_pool_allocator = True
from rmm import rmm_cfg

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why rename config to cfg? Seems like config is just a little bit more clear and nicer looking



@pytest.mark.parametrize('dtype,nelem', list(product(_dtypes, _nelems)))
@pytest.mark.parametrize("dtype,nelem", list(product(_dtypes, _nelems)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only test np.int32?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't modify these tests at all, only ran them through isort / black 😁

@kkraus14

Copy link
Copy Markdown
Contributor Author

Closing as this is superceded by #137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for review Ready for review by team Python Related to RMM Python API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA] Replace CFFI bindings with Cython

4 participants