Skip to content

Commit a0571fb

Browse files
committed
fix error passing host pointer to gpu kernel
1 parent 3ac0de2 commit a0571fb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/module_hsolver/precondition_funcs.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ namespace hsolver
101101
const FVal_t& transval = fval::none<Real<T>>)
102102
: prevec_(prevec), dim_(dim), transvec_(transvec), transval_(transval)
103103
{
104+
using syncmem_var_h2d_op = base_device::memory::synchronize_memory_op<Real<T>, Device, base_device::DEVICE_CPU>;
104105
this->dev_ = base_device::get_device_type<Device>(this->ctx_);
105106
#if defined(__CUDA) || defined(__ROCM)
106107
if (this->dev_ == base_device::GpuDevice) {
107108
resmem_real_op()(this->ctx_, this->d_prevec_, dim_);
109+
base_device::DEVICE_CPU* cpu_ctx = {};
110+
syncmem_var_h2d_op()(this->ctx_, cpu_ctx, this->d_prevec_, prevec_, dim_);
108111
}
109112
#endif
110113
}
@@ -120,7 +123,8 @@ namespace hsolver
120123
fvec::Div<T> get() const
121124
{
122125
return std::bind(PreOP<T, Device, Kernel_t>::transvec_,
123-
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, this->prevec_);
126+
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4,
127+
this->dev_ == base_device::GpuDevice ? this->d_prevec_ : this->prevec_);
124128
}
125129
template<typename U = Kernel_t, typename std::enable_if<std::is_same<U, fvec::DivTransMinusEigKernel<T, Device>>::value, bool>::type = 0>
126130
fvec::DivTransMinusEig<T> get() const

0 commit comments

Comments
 (0)