Hi everyone,
In the process of adding scheduler-matrix support to the wrapper, I got
a bit stuck on a bug that I caused by not initialising my not
initialising the matrix to which I was trying to assign a result. I
think it's sensible to throw a different exception from "not
implemented" in these cases, so I patched all the occurrences where that
would be meaningful. If you agree, the patch is attached :)
Toby
diff --git a/viennacl/backend/memory.hpp b/viennacl/backend/memory.hpp
index 8ea2d0f..bf5f5ef 100644
--- a/viennacl/backend/memory.hpp
+++ b/viennacl/backend/memory.hpp
@@ -108,6 +108,9 @@ namespace viennacl
handle.raw_size(size_in_bytes);
break;
#endif
+ case MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "unknown memory handle!";
}
@@ -158,6 +161,9 @@ namespace viennacl
cuda::memory_copy(src_buffer.cuda_handle(), dst_buffer.cuda_handle(), src_offset, dst_offset, bytes_to_copy);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "unknown memory handle!";
}
@@ -194,6 +200,9 @@ namespace viennacl
dst_buffer.raw_size(src_buffer.raw_size());
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "unknown memory handle!";
}
@@ -230,7 +239,10 @@ namespace viennacl
case CUDA_MEMORY:
cuda::memory_write(dst_buffer.cuda_handle(), dst_offset, bytes_to_write, ptr, async);
break;
-#endif
+#endi
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "unknown memory handle!";
}
@@ -271,6 +283,9 @@ namespace viennacl
cuda::memory_read(src_buffer.cuda_handle(), src_offset, bytes_to_read, ptr, async);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "unknown memory handle!";
}
diff --git a/viennacl/linalg/direct_solve.hpp b/viennacl/linalg/direct_solve.hpp
index 5928890..975ed39 100644
--- a/viennacl/linalg/direct_solve.hpp
+++ b/viennacl/linalg/direct_solve.hpp
@@ -71,6 +71,9 @@ namespace viennacl
viennacl::linalg::cuda::inplace_solve(A, B, SOLVERTAG());
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -104,6 +107,9 @@ namespace viennacl
viennacl::linalg::cuda::inplace_solve(A, proxy_B, SOLVERTAG());
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -138,6 +144,9 @@ namespace viennacl
viennacl::linalg::cuda::inplace_solve(proxy_A, B, SOLVERTAG());
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -171,6 +180,9 @@ namespace viennacl
viennacl::linalg::cuda::inplace_solve(proxy_A, proxy_B, SOLVERTAG());
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -203,6 +215,9 @@ namespace viennacl
viennacl::linalg::cuda::inplace_solve(mat, vec, SOLVERTAG());
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -236,6 +251,9 @@ namespace viennacl
viennacl::linalg::cuda::inplace_solve(proxy, vec, SOLVERTAG());
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
diff --git a/viennacl/linalg/matrix_operations.hpp b/viennacl/linalg/matrix_operations.hpp
index 4b58e66..58f8580 100644
--- a/viennacl/linalg/matrix_operations.hpp
+++ b/viennacl/linalg/matrix_operations.hpp
@@ -69,6 +69,9 @@ namespace viennacl
viennacl::linalg::cuda::am(mat1, mat2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -102,6 +105,9 @@ namespace viennacl
mat3, beta, len_beta, reciprocal_beta, flip_sign_beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -135,6 +141,9 @@ namespace viennacl
mat3, beta, len_beta, reciprocal_beta, flip_sign_beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -159,6 +168,9 @@ namespace viennacl
viennacl::linalg::cuda::matrix_assign(mat, s);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -183,6 +195,9 @@ namespace viennacl
viennacl::linalg::cuda::matrix_diagonal_assign(mat, s);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -228,6 +243,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(mat, vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -267,6 +285,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(mat_trans, vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -309,6 +330,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(A, B, C, alpha, beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -349,6 +373,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(A, B, C, alpha, beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -388,6 +415,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(A, B, C, alpha, beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -426,6 +456,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(A, B, C, alpha, beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -463,6 +496,9 @@ namespace viennacl
viennacl::linalg::cuda::element_op(A, proxy);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -656,6 +692,9 @@ namespace viennacl
vec1, vec2);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
diff --git a/viennacl/linalg/misc_operations.hpp b/viennacl/linalg/misc_operations.hpp
index d531bb8..6aadc14 100644
--- a/viennacl/linalg/misc_operations.hpp
+++ b/viennacl/linalg/misc_operations.hpp
@@ -74,6 +74,9 @@ namespace viennacl
viennacl::linalg::cuda::detail::level_scheduling_substitute(vec, row_index_array, row_buffer, col_buffer, element_buffer, num_rows);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
diff --git a/viennacl/linalg/scalar_operations.hpp b/viennacl/linalg/scalar_operations.hpp
index 9455c20..98efcde 100644
--- a/viennacl/linalg/scalar_operations.hpp
+++ b/viennacl/linalg/scalar_operations.hpp
@@ -81,6 +81,9 @@ namespace viennacl
viennacl::linalg::cuda::as(s1, s2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -135,6 +138,9 @@ namespace viennacl
s3, beta, len_beta, reciprocal_beta, flip_sign_beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -189,6 +195,9 @@ namespace viennacl
s3, beta, len_beta, reciprocal_beta, flip_sign_beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -222,6 +231,9 @@ namespace viennacl
viennacl::linalg::cuda::swap(s1, s2);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
diff --git a/viennacl/linalg/sparse_matrix_operations.hpp b/viennacl/linalg/sparse_matrix_operations.hpp
index 678149e..4b3fbc1 100644
--- a/viennacl/linalg/sparse_matrix_operations.hpp
+++ b/viennacl/linalg/sparse_matrix_operations.hpp
@@ -66,6 +66,9 @@ namespace viennacl
viennacl::linalg::cuda::detail::row_info(mat, vec, info_selector);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -109,6 +112,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(mat, vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -148,6 +154,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(sp_mat, d_mat, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -188,6 +197,9 @@ namespace viennacl
viennacl::linalg::cuda::prod_impl(sp_mat, d_mat, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -223,6 +235,9 @@ namespace viennacl
viennacl::linalg::cuda::inplace_solve(mat, vec, tag);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -259,6 +274,9 @@ namespace viennacl
viennacl::linalg::cuda::inplace_solve(mat, vec, tag);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -295,6 +313,9 @@ namespace viennacl
viennacl::linalg::cuda::detail::block_inplace_solve(mat, block_index_array, num_blocks, mat_diagonal, vec, tag);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
diff --git a/viennacl/linalg/vector_operations.hpp b/viennacl/linalg/vector_operations.hpp
index 62742f2..db0cee9 100644
--- a/viennacl/linalg/vector_operations.hpp
+++ b/viennacl/linalg/vector_operations.hpp
@@ -66,6 +66,9 @@ namespace viennacl
viennacl::linalg::cuda::av(vec1, vec2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -101,6 +104,9 @@ namespace viennacl
vec3, beta, len_beta, reciprocal_beta, flip_sign_beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -136,6 +142,9 @@ namespace viennacl
vec3, beta, len_beta, reciprocal_beta, flip_sign_beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -165,6 +174,9 @@ namespace viennacl
viennacl::linalg::cuda::vector_assign(vec1, alpha);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -196,6 +208,9 @@ namespace viennacl
viennacl::linalg::cuda::vector_swap(vec1, vec2);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -232,6 +247,9 @@ namespace viennacl
viennacl::linalg::cuda::element_op(vec1, proxy);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -392,6 +410,9 @@ namespace viennacl
viennacl::linalg::cuda::inner_prod_impl(vec1, vec2, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -462,6 +483,9 @@ namespace viennacl
viennacl::linalg::cuda::inner_prod_cpu(vec1, vec2, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -532,6 +556,9 @@ namespace viennacl
viennacl::linalg::cuda::inner_prod_impl(x, y_tuple, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -562,6 +589,9 @@ namespace viennacl
viennacl::linalg::cuda::norm_1_impl(vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -607,6 +637,9 @@ namespace viennacl
viennacl::linalg::cuda::norm_1_cpu(vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -652,6 +685,9 @@ namespace viennacl
viennacl::linalg::cuda::norm_2_impl(vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -695,6 +731,9 @@ namespace viennacl
viennacl::linalg::cuda::norm_2_cpu(vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -740,6 +779,9 @@ namespace viennacl
viennacl::linalg::cuda::norm_inf_impl(vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -783,6 +825,9 @@ namespace viennacl
viennacl::linalg::cuda::norm_inf_cpu(vec, result);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -825,6 +870,9 @@ namespace viennacl
case viennacl::CUDA_MEMORY:
return viennacl::linalg::cuda::index_norm_inf(vec);
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
@@ -871,6 +919,9 @@ namespace viennacl
viennacl::linalg::cuda::plane_rotation(vec1, vec2, alpha, beta);
break;
#endif
+ case viennacl::MEMORY_NOT_INITIALIZED:
+ throw "not initialised!";
+ break;
default:
throw "not implemented";
}
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
ViennaCL-devel mailing list
ViennaCL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-devel