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
linalg sum method #3278
linalg sum method #3278
Conversation
#ifdef HAVE_VIENNACL | ||
return viennacl::linalg::sum(vec.gpuarray->GPUvec()); | ||
#else | ||
SG_SERROR("User did not register GPU backend. \n"); |
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 don't like it if we would have to put this error message in every implementation.
Minor: No space after period.
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.
why do we generate at all GPUBackend
class if there's no gpu backend? i'm sorry but i'm very very confused what's happening here...
you should implement a GPUBackend
using for example viannacl IF it's available. if not you just don't create one. like many other models, that if LAPACK was not present, the implementation was not built.
@OXPHOS hey! Can you quickly change the implementation of vector class based on what we had discussed? It is better to be done in the initial phase before we add too many methods (easy to change now than later). So the idea is that there will only be one class for vector, something like class GPUVectorImpl; // this is the GPUArray thing that you have
template <typename T>
class Vector
{
public:
Vector(SGVector<T> const &);
Vector& operator=(SGVector<T> const &);
operator SGVector<T>() const;
bool onGPU() const;
T* data();
T const * data() const;
index_t size() const;
private:
bool m_onGPU; // this variable would be assessed in every linalg call,
// makes sense to put this first
index_t m_len; // same logic
T* m_data; // non-owning ptr, referring to the SGVector.vector
unique_ptr<GPUVectorImpl> m_gpu_impl;
void transferToGPU();
void transferToCPU();
}; So, every time a call to
// vec1 and vec2 are SGVectors
auto v = sg_linalg->transferToGPU(vec1);
// do something with v
v = vec2;
// v.onGPU() == ?, should be false To achieve this, all we have to do is the set
Also, think a bit about thread safety while updating the @karlnapf @vigsterkr @lisitsyn please share your thoughts and suggestions. |
Maybe it is a good idea to keep the refcount as well? |
No description provided.