@@ -34,7 +34,6 @@ class block_
3434
3535 protected:
3636 int start_row_, start_col_, rows_, cols_;
37- using base::arguments_;
3837
3938 public:
4039 /* *
@@ -61,8 +60,8 @@ class block_
6160 * Creates a deep copy of this expression.
6261 * @return copy of \c *this
6362 */
64- inline auto deep_copy () {
65- auto && arg_copy = std::get <0 >(arguments_ ).deep_copy ();
63+ inline auto deep_copy () const {
64+ auto && arg_copy = this -> template get_arg <0 >().deep_copy ();
6665 return block_<std::remove_reference_t <decltype (arg_copy)>>{
6766 std::move (arg_copy), start_row_, start_col_, rows_, cols_};
6867 }
@@ -122,7 +121,7 @@ class block_
122121 cl::Kernel& kernel, int & arg_num) const {
123122 if (generated.count (this ) == 0 ) {
124123 generated.insert (this );
125- std::get <0 >(arguments_ ).set_args (generated, kernel, arg_num);
124+ this -> template get_arg <0 >().set_args (generated, kernel, arg_num);
126125 kernel.setArg (arg_num++, start_row_);
127126 kernel.setArg (arg_num++, start_col_);
128127 }
@@ -175,9 +174,9 @@ class block_
175174 inline void set_view (int bottom_diagonal, int top_diagonal,
176175 int bottom_zero_diagonal, int top_zero_diagonal) const {
177176 int change = start_col_ - start_row_;
178- std::get <0 >(arguments_)
179- . set_view ( bottom_diagonal + change, top_diagonal + change,
180- bottom_zero_diagonal + change, top_zero_diagonal + change);
177+ this -> template get_arg <0 >(). set_view (
178+ bottom_diagonal + change, top_diagonal + change,
179+ bottom_zero_diagonal + change, top_zero_diagonal + change);
181180 }
182181
183182 /* *
@@ -186,7 +185,7 @@ class block_
186185 */
187186 inline int bottom_diagonal () const {
188187 return std::max (
189- std::get <0 >(arguments_ ).bottom_diagonal () - start_col_ + start_row_,
188+ this -> template get_arg <0 >().bottom_diagonal () - start_col_ + start_row_,
190189 1 - rows_);
191190 }
192191
@@ -196,7 +195,7 @@ class block_
196195 */
197196 inline int top_diagonal () const {
198197 return std::min (
199- std::get <0 >(arguments_ ).top_diagonal () - start_col_ + start_row_,
198+ this -> template get_arg <0 >().top_diagonal () - start_col_ + start_row_,
200199 cols_ - 1 );
201200 }
202201
@@ -234,6 +233,14 @@ class block_
234233
235234/* *
236235 * Block of a kernel generator expression.
236+ *
237+ * Block operation modifies how its argument is indexed. If a matrix is both an
238+ * argument and result of such an operation (such as in <code> block(a, row1,
239+ * col1, rows, cols) = block(a, row2, col2, rows, cols);
240+ * </code>), the result can be wrong due to aliasing. In such case the
241+ * expression should be evaluating in a temporary by doing <code> block(a, row1,
242+ * col1, rows, cols) = block(a, row2, col2, rows, cols).eval();</code>. This is
243+ * not necessary if the bolcks do not overlap or if they are the same block.
237244 * @tparam T type of argument
238245 * @param a input argument
239246 * @param start_row first row of block
0 commit comments