diff src/pt-jit.cc @ 15078:fe4752f772e2

Generate ND indexing functions on demand in JIT. * src/jit-typeinfo.cc (jit_operation::~jit_operation, jit_operation::do_generate, jit_operation::generate, jit_operation::signature_cmp::operator()): New function. (jit_operation::overload): Call do_generate when lookup fails. (jit_index_operation, jit_paren_subsref, jit_paren_subsasgn): New class. (jit_typeinfo::jit_typeinfo): Update to use jit_paren_subsref and jit_paren_subsasgn. (jit_typeinfo::gen_subsref, jit_typeinfo::gen_subsasgn): Removed functions. * src/jit-typeinfo.h (jit_operation::~jit_operation, jit_operation::generate, jit_operation::do_generate): New declaration. (jit_operation::add_overload, jit_operation::overload, jit_operation::result, jit_operation::to_idx): Use signature_vec typedef. (jit_operation::singature_cmp): New class. (jit_index_operation, jit_paren_subsref, jit_paren_subsasgn): New class. (jit_typeinfo::get_scalar_ptr): Nwe function. (jit_typeinfo::gen_subsref, jit_typeinfo::gen_subsasgn): Removed declaration. * src/pt-jit.cc: New test.
author Max Brister <max@2bass.com>
date Wed, 01 Aug 2012 17:00:12 -0500
parents f57d7578c1a6
children 9df70a18aa27
line wrap: on
line diff
--- a/src/pt-jit.cc	Wed Aug 01 12:10:26 2012 -0400
+++ b/src/pt-jit.cc	Wed Aug 01 17:00:12 2012 -0500
@@ -1883,4 +1883,25 @@
 %! m2(:) = 1:(ndim^2);
 %! assert (all (m == m2));
 
+%!test
+%! ndim = 2;
+%! m = zeros (ndim, ndim, ndim, ndim);
+%! result = 0;
+%! i0 = 1;
+%! while (i0 <= ndim)
+%!   for i1 = 1:ndim
+%!     for i2 = 1:ndim
+%!       for i3 = 1:ndim
+%!         m(i0, i1, i2, i3) = 1;
+%!         m(i0, i1, i2, i3, 1, 1, 1, 1, 1, 1) = 1;
+%!         result = result + m(i0, i1, i2, i3);
+%!       endfor
+%!     endfor
+%!   endfor
+%!   i0 = i0 + 1;
+%! endwhile
+%! expected = ones (ndim, ndim, ndim, ndim);
+%! assert (all (m == expected));
+%! assert (result == sum (expected (:)));
+
 */