clsparseStatus cldenseSscale (cldenseVector* y, const clsparseScalar* alpha, const clsparseControl control) { if (!clsparseInitialized) { return clsparseNotInitialized; } if (control == nullptr) { return clsparseInvalidControlObject; } clsparse::vector<cl_float> pY(control, y->values, y->num_values ); clsparse::vector<cl_float> pAlpha(control, alpha->value, 1); cl_float pattern = 0.0f; if (pAlpha[0] == 0.f) { cl_int status = pY.fill(control, pattern); if (status != CL_SUCCESS) { return clsparseInvalidKernelExecution; } return clsparseSuccess; } return scale(pY, pAlpha, control); }
clsparseStatus cldenseDaxpy(cldenseVector *r, const clsparseScalar *alpha, const cldenseVector *x, const cldenseVector *y, const clsparseControl control) { if (!clsparseInitialized) { return clsparseNotInitialized; } //check opencl elements if (control == nullptr) { return clsparseInvalidControlObject; } clsparse::vector<cl_double> pR (control, r->values, r->num_values); clsparse::vector<cl_double> pAlpha(control, alpha->value, 1); clsparse::vector<cl_double> pX (control, x->values, x->num_values); clsparse::vector<cl_double> pY (control, y->values, y->num_values); assert(pR.size() == pY.size()); assert(pR.size() == pX.size()); cl_ulong size = pR.size(); if(size == 0) return clsparseSuccess; //nothing to do if (pAlpha[0] == 0.0) { auto pRBuff = pR.data()(); auto pYBuff = pY.data()(); //if R is different pointer than Y than copy Y to R if (pRBuff != pYBuff) { // deep copy; pR = pY; } return clsparseSuccess; } return axpy(pR, pAlpha, pX, pY, control); }
void TILE :: display() { draw_at(pX(),pY()); }