Skip to content

how to transfer an allocated array on GPU to solver-apply #1132

Answered by yhmtsai
ztdepztdep asked this question in Q&A
Discussion options

You must be logged in to vote

I copy my reply from the same discussion #1131

Are the type of d_b and d_x double*?
If they are, the solver needs to use the gko::matrix::Dense<double>* type.
You can create the Dense matrix by reading a mtx file.
ex. gko::read<gko::matrix::Dense<>>(std::ifstream("filepath"), exec);
or create the Dense first then fill in the data

auto x = gko::matrix::Dense<>::create(exec, gko::dim<2>(n, 1));
// copy the data to x->get_values()

or create the Dense on the preallocated array
auto x = gko::matrix::Dense<>::create(exec, gko::dim<2>(n, 1), gko::array<double>::view(exec, n, d_x));
note. array view to indicate the size and location for the plain pointer.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ztdepztdep
Comment options

@yhmtsai
Comment options

yhmtsai Oct 27, 2022
Collaborator

Answer selected by pratikvn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
is:question This is a question to the developers.
3 participants
Converted from issue

This discussion was converted from issue #1129 on October 05, 2022 05:50.