-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add single-value access functions for array
access
#1485
Conversation
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.
More places to replace:
- common/unified/matrix/dense_kernels.template.cpp:281
- core/baser/index_set.cpp:84
- core/factorization/par_ict.cpp:170|189|191
- core/matrix/sparsity_csr.cpp:136
- dpcpp/matrix/csr_kernels.dp.cpp:2632
@MarcelKoch thanks, I replaced them |
@pratikvn Our types are first and foremost used by our code, and an array class that doesn't provide access to its values is at least inconvenient. Thrust has |
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.
I still think the names load_value
and store_value
are misleading. In particular, because in my view load
and store
are verbs that are generally used for low level operations.
But I wont hold back the PR.
@pratikvn We have a kind of tendency in Ginkgo to give things elaborate names I agree that |
In the latest state I added an accessor/device_reference-based interface, which has a slight readability advantage for writing values: array.set_value(0, 1); // which is the index, which the value?
array.get_access()[0] = 0; // here it's clear Still, these kinds of accessors bring all kinds of issues (e.g. the need to implement a lot of custom operators for cases where the matching operator is implemented with a template function, e.g. in std::complex) |
Maybe going back one step and just implement
in a private header would be the better choice right now. From the discussion, this would be rather uncontroversial and already fixes the use cases we want to target here. |
As the least intrusive version, I now moved to an internal access function |
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.
LGTM!
|
This adds bounds-checked
array::load_value(size_type)
andarray::store_value(size_type, T)
functions and uses them where possible