Mercurial > hg > octave-nkf
changeset 15025:f23e60748072
Merge in Doug's changes
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 26 Jul 2012 14:36:25 -0400 |
parents | a031f7d515b2 (current diff) 75d1bc2fd6d2 (diff) |
children | ae42d5a67ed9 |
files | |
diffstat | 39 files changed, 282 insertions(+), 162 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array-util.cc +++ b/liboctave/Array-util.cc @@ -426,7 +426,7 @@ { int ial = ia.length (), rhdvl = rhdv.length (); dim_vector rdv = dim_vector::alloc (ial); - bool *scalar = new bool[ial], *colon = new bool[ial]; + bool *scalar = new bool [ial], *colon = new bool [ial]; // Mark scalars and colons, count non-scalar indices. int nonsc = 0; bool all_colons = true;
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -649,7 +649,7 @@ int i = 0; for (; i < l-1 && ndv(i) == odv(i); i++) ld *= ndv(i); n = l - i; - cext = new octave_idx_type[3*n]; + cext = new octave_idx_type [3*n]; // Trick to avoid three allocations sext = cext + n; dext = sext + n;
--- a/liboctave/DASPK.cc +++ b/liboctave/DASPK.cc @@ -145,7 +145,7 @@ for (octave_idx_type j = 0; j < nn; j++) for (octave_idx_type i = 0; i < nn; i++) - pd [nn * j + i] = tmp_pd.elem (i, j); + pd[nn * j + i] = tmp_pd.elem (i, j); END_INTERRUPT_WITH_EXCEPTIONS;
--- a/liboctave/DASRT.cc +++ b/liboctave/DASRT.cc @@ -121,7 +121,7 @@ for (octave_idx_type j = 0; j < nn; j++) for (octave_idx_type i = 0; i < nn; i++) - pd [nn * j + i] = tmp_pd.elem (i, j); + pd[nn * j + i] = tmp_pd.elem (i, j); END_INTERRUPT_WITH_EXCEPTIONS;
--- a/liboctave/DASSL.cc +++ b/liboctave/DASSL.cc @@ -119,7 +119,7 @@ for (octave_idx_type j = 0; j < nn; j++) for (octave_idx_type i = 0; i < nn; i++) - pd [nn * j + i] = tmp_pd.elem (i, j); + pd[nn * j + i] = tmp_pd.elem (i, j); END_INTERRUPT_WITH_EXCEPTIONS;
--- a/liboctave/LSODE.cc +++ b/liboctave/LSODE.cc @@ -103,7 +103,7 @@ for (octave_idx_type j = 0; j < neq; j++) for (octave_idx_type i = 0; i < neq; i++) - pd [nrowpd * j + i] = tmp_jac (i, j); + pd[nrowpd * j + i] = tmp_jac (i, j); END_INTERRUPT_WITH_EXCEPTIONS;
--- a/liboctave/MatrixType.cc +++ b/liboctave/MatrixType.cc @@ -51,7 +51,7 @@ { if (nperm != 0) { - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = a.perm[i]; } @@ -74,7 +74,7 @@ bool hermitian = true; // do the checks for lower/upper/hermitian all in one pass. - OCTAVE_LOCAL_BUFFER(T, diag, ncols); + OCTAVE_LOCAL_BUFFER (T, diag, ncols); for (octave_idx_type j = 0; j < ncols && upper; j++) @@ -132,7 +132,7 @@ bool hermitian = true; // do the checks for lower/upper/hermitian all in one pass. - OCTAVE_LOCAL_BUFFER(T, diag, ncols); + OCTAVE_LOCAL_BUFFER (T, diag, ncols); for (octave_idx_type j = 0; j < ncols && upper; j++) @@ -255,12 +255,12 @@ for (octave_idx_type j = i; j < nm; j++) { if ((a.cidx (j+1) > a.cidx (j) + 1) || - ((a.cidx (j+1) == a.cidx (j) + 1) && found [a.ridx (j)])) + ((a.cidx (j+1) == a.cidx (j) + 1) && found[a.ridx (j)])) { tmp_typ = MatrixType::Full; break; } - found [a.ridx (j)] = true; + found[a.ridx (j)] = true; } } typ = tmp_typ; @@ -348,7 +348,7 @@ bool found = false; nperm = ncols; - perm = new octave_idx_type[ncols]; + perm = new octave_idx_type [ncols]; for (octave_idx_type i = 0; i < ncols; i++) perm[i] = -1; @@ -387,7 +387,7 @@ { nperm = nrows; delete [] perm; - perm = new octave_idx_type[nrows]; + perm = new octave_idx_type [nrows]; OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, nrows); for (octave_idx_type i = 0; i < nrows; i++) @@ -398,7 +398,7 @@ for (octave_idx_type j = 0; j < ncols; j++) for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) - perm [a.ridx (i)] = j; + perm[a.ridx (i)] = j; found = true; for (octave_idx_type i = 0; i < nm; i++) @@ -576,12 +576,12 @@ for (octave_idx_type j = i; j < nm; j++) { if ((a.cidx (j+1) > a.cidx (j) + 1) || - ((a.cidx (j+1) == a.cidx (j) + 1) && found [a.ridx (j)])) + ((a.cidx (j+1) == a.cidx (j) + 1) && found[a.ridx (j)])) { tmp_typ = MatrixType::Full; break; } - found [a.ridx (j)] = true; + found[a.ridx (j)] = true; } } typ = tmp_typ; @@ -669,7 +669,7 @@ bool found = false; nperm = ncols; - perm = new octave_idx_type[ncols]; + perm = new octave_idx_type [ncols]; for (octave_idx_type i = 0; i < ncols; i++) perm[i] = -1; @@ -708,7 +708,7 @@ { nperm = nrows; delete [] perm; - perm = new octave_idx_type[nrows]; + perm = new octave_idx_type [nrows]; OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, nrows); for (octave_idx_type i = 0; i < nrows; i++) @@ -719,7 +719,7 @@ for (octave_idx_type j = 0; j < ncols; j++) for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) - perm [a.ridx (i)] = j; + perm[a.ridx (i)] = j; found = true; for (octave_idx_type i = 0; i < nm; i++) @@ -876,7 +876,7 @@ { typ = t; nperm = np; - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = p[i]; } @@ -989,7 +989,7 @@ if (nperm != 0) { - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = tmp_typ.perm[i]; } @@ -1022,7 +1022,7 @@ if (nperm != 0) { - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = tmp_typ.perm[i]; } @@ -1049,7 +1049,7 @@ if (nperm != 0) { - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = tmp_typ.perm[i]; } @@ -1076,7 +1076,7 @@ if (nperm != 0) { - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = tmp_typ.perm[i]; } @@ -1103,7 +1103,7 @@ if (nperm != 0) { - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = tmp_typ.perm[i]; } @@ -1130,7 +1130,7 @@ if (nperm != 0) { - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = tmp_typ.perm[i]; } @@ -1225,7 +1225,7 @@ MatrixType::mark_as_permuted (const octave_idx_type np, const octave_idx_type *p) { nperm = np; - perm = new octave_idx_type[nperm]; + perm = new octave_idx_type [nperm]; for (octave_idx_type i = 0; i < nperm; i++) perm[i] = p[i];
--- a/liboctave/Sparse-perm-op-defs.h +++ b/liboctave/Sparse-perm-op-defs.h @@ -71,7 +71,7 @@ { // Form the column permutation and then call the colpm_sm routine. const octave_idx_type *prow = p.pvec ().data (); - OCTAVE_LOCAL_BUFFER(octave_idx_type, pcol, nr); + OCTAVE_LOCAL_BUFFER (octave_idx_type, pcol, nr); for (octave_idx_type i = 0; i < nr; ++i) pcol[prow[i]] = i; return octinternal_do_mul_colpm_sm (pcol, a);
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -176,13 +176,13 @@ // Reallocate. octave_idx_type min_nzmx = std::min (nz, nzmx); - octave_idx_type * new_ridx = new octave_idx_type[nz]; + octave_idx_type * new_ridx = new octave_idx_type [nz]; copy_or_memcpy (min_nzmx, r, new_ridx); delete [] r; r = new_ridx; - T * new_data = new T[nz]; + T * new_data = new T [nz]; copy_or_memcpy (min_nzmx, d, new_data); delete [] d;
--- a/liboctave/Sparse.h +++ b/liboctave/Sparse.h @@ -72,7 +72,7 @@ octave_refcount<int> count; SparseRep (void) - : d (0), r (0), c (new octave_idx_type[1]), nzmx (0), nrows (0), + : d (0), r (0), c (new octave_idx_type [1]), nzmx (0), nrows (0), ncols (0), count (1) { c[0] = 0; @@ -87,7 +87,7 @@ } SparseRep (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz = 0) - : d (new T[nz]), r (new octave_idx_type[nz]), + : d (new T [nz]), r (new octave_idx_type [nz]), c (new octave_idx_type [nc+1]), nzmx (nz), nrows (nr), ncols (nc), count (1) {
--- a/liboctave/dim-vector.h +++ b/liboctave/dim-vector.h @@ -66,7 +66,7 @@ static octave_idx_type *newrep (int ndims) { - octave_idx_type *r = new octave_idx_type[ndims + 2]; + octave_idx_type *r = new octave_idx_type [ndims + 2]; *r++ = 1; *r++ = ndims; @@ -80,7 +80,7 @@ { int l = ndims (); - octave_idx_type *r = new octave_idx_type[l + 2]; + octave_idx_type *r = new octave_idx_type [l + 2]; *r++ = 1; *r++ = l; @@ -100,7 +100,7 @@ if (n < 2) n = 2; - octave_idx_type *r = new octave_idx_type[n + 2]; + octave_idx_type *r = new octave_idx_type [n + 2]; *r++ = 1; *r++ = n;
--- a/liboctave/eigs-base.cc +++ b/liboctave/eigs-base.cc @@ -1969,7 +1969,7 @@ if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0) jj++; else - d [i-jj] = Complex (dr[i], di[i]); + d[i-jj] = Complex (dr[i], di[i]); } if (jj == 0 && !rvec) for (octave_idx_type i = 0; i < k; i++) @@ -2355,7 +2355,7 @@ if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0) jj++; else - d [i-jj] = Complex (dr[i], di[i]); + d[i-jj] = Complex (dr[i], di[i]); } if (jj == 0 && !rvec) for (octave_idx_type i = 0; i < k; i++) @@ -2667,7 +2667,7 @@ if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0) jj++; else - d [i-jj] = Complex (dr[i], di[i]); + d[i-jj] = Complex (dr[i], di[i]); } if (jj == 0 && !rvec) for (octave_idx_type i = 0; i < k; i++)
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -325,7 +325,7 @@ { if (len != 0) { - octave_idx_type *d = new octave_idx_type[len]; + octave_idx_type *d = new octave_idx_type [len]; for (octave_idx_type i = 0; i < len; i++) d[i] = convert_index (nda.xelem (i), err, ext); data = d; @@ -385,7 +385,7 @@ { if (len != 0) { - octave_idx_type *d = new octave_idx_type[1]; + octave_idx_type *d = new octave_idx_type [1]; d[0] = 0; data = d; ext = 1; @@ -407,7 +407,7 @@ if (len != 0) { - octave_idx_type *d = new octave_idx_type[len]; + octave_idx_type *d = new octave_idx_type [len]; octave_idx_type ntot = bnda.length (); @@ -435,7 +435,7 @@ if (len != 0) { - octave_idx_type *d = new octave_idx_type[len]; + octave_idx_type *d = new octave_idx_type [len]; octave_idx_type nnz = bnda.nnz (); @@ -489,7 +489,7 @@ if (ext > len*xlog2 (1.0 + len)) { // Use standard sort via octave_sort. - octave_idx_type *new_data = new octave_idx_type[len]; + octave_idx_type *new_data = new octave_idx_type [len]; new_rep->data = new_data; std::copy (data, data + len, new_data); @@ -524,7 +524,7 @@ else new_rep->orig_dims = dim_vector (new_len, 1); - octave_idx_type *new_data = new octave_idx_type[new_len]; + octave_idx_type *new_data = new octave_idx_type [new_len]; new_rep->data = new_data; for (octave_idx_type i = 0, j = 0; i < ext; i++) @@ -538,7 +538,7 @@ for (octave_idx_type i = 0; i < len; i++) cnt[data[i]]++; - octave_idx_type *new_data = new octave_idx_type[len]; + octave_idx_type *new_data = new octave_idx_type [len]; new_rep->data = new_data; for (octave_idx_type i = 0, j = 0; i < ext; i++) @@ -566,7 +566,7 @@ for (octave_idx_type i = 0; i < len; i++) idx_data[i] = i; - octave_idx_type *new_data = new octave_idx_type[len]; + octave_idx_type *new_data = new octave_idx_type [len]; new_rep->data = new_data; std::copy (data, data + len, new_data); @@ -585,7 +585,7 @@ idx.clear (orig_dims); octave_idx_type *idx_data = idx.fortran_vec (); - octave_idx_type *new_data = new octave_idx_type[len]; + octave_idx_type *new_data = new octave_idx_type [len]; new_rep->data = new_data; for (octave_idx_type i = 0, k = 0; i < ext; i++) @@ -654,7 +654,7 @@ { if (len != 0) { - bool *d = new bool[1]; + bool *d = new bool [1]; d[0] = true; data = d; ext = 1; @@ -1210,7 +1210,7 @@ idx_mask_rep * r = dynamic_cast<idx_mask_rep *> (rep); const bool *data = r->get_data (); octave_idx_type ext = r->extent (0), len = r->length (0); - octave_idx_type *idata = new octave_idx_type[len]; + octave_idx_type *idata = new octave_idx_type [len]; for (octave_idx_type i = 0, j = 0; i < ext; i++) if (data[i])
--- a/liboctave/oct-alloc.cc +++ b/liboctave/oct-alloc.cc @@ -32,7 +32,7 @@ octave_allocator::alloc (size_t size) { if (size != item_size) - return ::new char[size]; + return ::new char [size]; if (! head) {
--- a/liboctave/oct-locbuf.cc +++ b/liboctave/oct-locbuf.cc @@ -74,11 +74,11 @@ { // Use new [] to get std::bad_alloc if out of memory. - dat = new char[size]; + dat = new char [size]; return; } - dat = new char[chunk_size]; + dat = new char [chunk_size]; chunk = top = dat; left = chunk_size; }
--- a/liboctave/oct-locbuf.h +++ b/liboctave/oct-locbuf.h @@ -38,7 +38,7 @@ : data (0) { if (size) - data = new T[size]; + data = new T [size]; } ~octave_local_buffer (void) { delete [] data; } operator T *() const { return data; } @@ -204,7 +204,7 @@ // about shadowed parameters. #define OCTAVE_LOCAL_BUFFER_INIT(T, buf, size, value) \ - OCTAVE_LOCAL_BUFFER(T, buf, size); \ + OCTAVE_LOCAL_BUFFER (T, buf, size); \ for (size_t _buf_iter = 0, _buf_size = size; \ _buf_iter < _buf_size; _buf_iter++) \ buf[_buf_iter] = value
--- a/liboctave/oct-mem.h +++ b/liboctave/oct-mem.h @@ -128,7 +128,7 @@ // Some systems let us allocate > 2GB memory even though size_t, which is either // buggy or completely cuckoo, so let's check here to stay safe. safe_size_comp (n, sizeof (T)); - return new T[n]; + return new T [n]; } template <class T> inline void no_ctor_delete (T *ptr) @@ -137,7 +137,7 @@ #define DEFINE_POD_NEW_DELETE(T) \ template <> \ inline T *no_ctor_new<T > (size_t n) \ -{ return reinterpret_cast<T *> (new char[safe_size_comp (n, sizeof (T))]); } \ +{ return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \ template <> \ inline void no_ctor_delete<T > (T *ptr) \ { delete [] reinterpret_cast<char *> (ptr); }
--- a/liboctave/oct-sort.cc +++ b/liboctave/oct-sort.cc @@ -542,7 +542,7 @@ */ delete [] a; delete [] ia; // Must do this or fool possible next getmemi. - a = new T[need]; + a = new T [need]; alloced = need; } @@ -561,8 +561,8 @@ delete [] a; delete [] ia; - a = new T[need]; - ia = new octave_idx_type[need]; + a = new T [need]; + ia = new octave_idx_type [need]; alloced = need; }
--- a/liboctave/oct-time.cc +++ b/liboctave/oct-time.cc @@ -175,7 +175,7 @@ while (chars_written == 0) { delete [] buf; - buf = new char[bufsize]; + buf = new char [bufsize]; buf[0] = '\0'; chars_written = nstrftime (buf, bufsize, fmt_str, &t, 0, 0);
--- a/liboctave/sparse-base-chol.cc +++ b/liboctave/sparse-base-chol.cc @@ -57,7 +57,7 @@ for (k = 0; k < ncol; k++) { p = Sp[k]; - pend = Sp [k+1]; + pend = Sp[k+1]; Sp[k] = pdest; for (; p < pend; p++) {
--- a/liboctave/sparse-dmsolve.cc +++ b/liboctave/sparse-dmsolve.cc @@ -59,7 +59,7 @@ for (octave_idx_type p = A.cidx (qq) ; p < A.cidx (qq+1) ; p++) { octave_quit (); - octave_idx_type r = (Pinv ? Pinv [A.ridx (p)] : A.ridx (p)); + octave_idx_type r = (Pinv ? Pinv[A.ridx (p)] : A.ridx (p)); if (r >= rst && r < rend) { B.xdata (nz) = A.data (p); @@ -82,16 +82,16 @@ for (octave_idx_type p = A.cidx (qq) ; p < A.cidx (qq+1) ; p++) { octave_quit (); - octave_idx_type r = (Pinv ? Pinv [A.ridx (p)] : A.ridx (p)); + octave_idx_type r = (Pinv ? Pinv[A.ridx (p)] : A.ridx (p)); if (r >= rst && r < rend) { - X [r-rst] = A.data (p); + X[r-rst] = A.data (p); B.xridx (nz++) = r - rst ; } } sort.sort (ri + B.xcidx (j - cst), nz - B.xcidx (j - cst)); for (octave_idx_type p = B.cidx (j - cst); p < nz; p++) - B.xdata (p) = X [B.xridx (p)]; + B.xdata (p) = X[B.xridx (p)]; } B.xcidx (cend - cst) = nz ; } @@ -170,7 +170,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - ax [Q [r + i] + aoff] = bx [i + boff]; + ax[Q[r + i] + aoff] = bx[i + boff]; } } } @@ -207,7 +207,7 @@ for (octave_idx_type i = c; i < c + b_cols; i++) for (octave_idx_type j = a.xcidx (i); j < a.xcidx (i+1); j++) - if (Qinv [a.xridx (j)] < r || Qinv [a.xridx (j)] >= r + b_rows) + if (Qinv[a.xridx (j)] < r || Qinv[a.xridx (j)] >= r + b_rows) nel++; OCTAVE_LOCAL_BUFFER (T, X, nr); @@ -231,9 +231,9 @@ octave_quit (); for (octave_idx_type j = tmp.xcidx (i); j < tmp.xcidx (i+1); j++) - if (Qinv [tmp.xridx (j)] < r || Qinv [tmp.xridx (j)] >= r + b_rows) + if (Qinv[tmp.xridx (j)] < r || Qinv[tmp.xridx (j)] >= r + b_rows) { - X [tmp.xridx (j)] = tmp.xdata (j); + X[tmp.xridx (j)] = tmp.xdata (j); a.xridx (ii++) = tmp.xridx (j); } @@ -241,13 +241,13 @@ for (octave_idx_type j = b.cidx (i-c); j < b.cidx (i-c+1); j++) { - X [Q [r + b.ridx (j)]] = b.data (j); - a.xridx (ii++) = Q [r + b.ridx (j)]; + X[Q[r + b.ridx (j)]] = b.data (j); + a.xridx (ii++) = Q[r + b.ridx (j)]; } sort.sort (ri + a.xcidx (i), ii - a.xcidx (i)); for (octave_idx_type p = a.xcidx (i); p < ii; p++) - a.xdata (p) = X [a.xridx (p)]; + a.xdata (p) = X[a.xridx (p)]; a.xcidx (i+1) = ii; } @@ -332,7 +332,7 @@ for (octave_idx_type i = a.cidx (j); i < nz; i++) { octave_quit (); - a.xdata (i) = X [a.xridx (i)]; + a.xdata (i) = X[a.xridx (i)]; } a.xcidx (j+1) = nz; }
--- a/src/DLD-FUNCTIONS/ccolamd.cc +++ b/src/DLD-FUNCTIONS/ccolamd.cc @@ -164,53 +164,53 @@ int nel_User_knobs = User_knobs.length (); if (nel_User_knobs > 0) - knobs [CCOLAMD_LU] = (User_knobs (0) != 0); + knobs[CCOLAMD_LU] = (User_knobs(0) != 0); if (nel_User_knobs > 1) - knobs [CCOLAMD_DENSE_ROW] = User_knobs (1); + knobs[CCOLAMD_DENSE_ROW] = User_knobs(1); if (nel_User_knobs > 2) - knobs [CCOLAMD_DENSE_COL] = User_knobs (2); + knobs[CCOLAMD_DENSE_COL] = User_knobs(2); if (nel_User_knobs > 3) - knobs [CCOLAMD_AGGRESSIVE] = (User_knobs (3) != 0); + knobs[CCOLAMD_AGGRESSIVE] = (User_knobs(3) != 0); if (nel_User_knobs > 4) - spumoni = (User_knobs (4) != 0); + spumoni = (User_knobs(4) != 0); // print knob settings if spumoni is set if (spumoni) { octave_stdout << "\nccolamd version " << CCOLAMD_MAIN_VERSION << "." << CCOLAMD_SUB_VERSION << ", " << CCOLAMD_DATE - << ":\nknobs(1): " << User_knobs (0) << ", order for "; - if ( knobs [CCOLAMD_LU] != 0) + << ":\nknobs(1): " << User_knobs(0) << ", order for "; + if (knobs[CCOLAMD_LU] != 0) octave_stdout << "lu (A)\n"; else octave_stdout << "chol (A'*A)\n"; - if (knobs [CCOLAMD_DENSE_ROW] >= 0) - octave_stdout << "knobs(2): " << User_knobs (1) + if (knobs[CCOLAMD_DENSE_ROW] >= 0) + octave_stdout << "knobs(2): " << User_knobs(1) << ", rows with > max (16," - << knobs [CCOLAMD_DENSE_ROW] << "*sqrt (size(A,2)))" + << knobs[CCOLAMD_DENSE_ROW] << "*sqrt (size(A,2)))" << " entries removed\n"; else - octave_stdout << "knobs(2): " << User_knobs (1) + octave_stdout << "knobs(2): " << User_knobs(1) << ", no dense rows removed\n"; - if (knobs [CCOLAMD_DENSE_COL] >= 0) - octave_stdout << "knobs(3): " << User_knobs (2) + if (knobs[CCOLAMD_DENSE_COL] >= 0) + octave_stdout << "knobs(3): " << User_knobs(2) << ", cols with > max (16," - << knobs [CCOLAMD_DENSE_COL] << "*sqrt (size(A)))" + << knobs[CCOLAMD_DENSE_COL] << "*sqrt (size(A)))" << " entries removed\n"; else - octave_stdout << "knobs(3): " << User_knobs (2) + octave_stdout << "knobs(3): " << User_knobs(2) << ", no dense columns removed\n"; - if (knobs [CCOLAMD_AGGRESSIVE] != 0) + if (knobs[CCOLAMD_AGGRESSIVE] != 0) octave_stdout << "knobs(4): " << User_knobs(3) << ", aggressive absorption: yes"; else octave_stdout << "knobs(4): " << User_knobs(3) << ", aggressive absorption: no"; - octave_stdout << "knobs(5): " << User_knobs (4) + octave_stdout << "knobs(5): " << User_knobs(4) << ", statistics and knobs printed\n"; } } @@ -259,12 +259,12 @@ // Allocate workspace for ccolamd OCTAVE_LOCAL_BUFFER (octave_idx_type, p, n_col+1); for (octave_idx_type i = 0; i < n_col+1; i++) - p[i] = cidx [i]; + p[i] = cidx[i]; octave_idx_type Alen = CCOLAMD_NAME (_recommended) (nnz, n_row, n_col); OCTAVE_LOCAL_BUFFER (octave_idx_type, A, Alen); for (octave_idx_type i = 0; i < nnz; i++) - A[i] = ridx [i]; + A[i] = ridx[i]; OCTAVE_LOCAL_BUFFER (octave_idx_type, stats, CCOLAMD_STATS); @@ -315,7 +315,7 @@ { NDArray out_stats (dim_vector (1, CCOLAMD_STATS)); for (octave_idx_type i = 0 ; i < CCOLAMD_STATS ; i++) - out_stats (i) = stats [i] ; + out_stats(i) = stats[i] ; retval(1) = out_stats; // fix stats (5) and (6), for 1-based information on @@ -419,11 +419,11 @@ int nel_User_knobs = User_knobs.length (); if (nel_User_knobs > 0) - knobs [CCOLAMD_DENSE_ROW] = User_knobs (0); + knobs[CCOLAMD_DENSE_ROW] = User_knobs(0); if (nel_User_knobs > 0) - knobs [CCOLAMD_AGGRESSIVE] = User_knobs (1); + knobs[CCOLAMD_AGGRESSIVE] = User_knobs(1); if (nel_User_knobs > 1) - spumoni = static_cast<int> (User_knobs (2)); + spumoni = static_cast<int> (User_knobs(2)); // print knob settings if spumoni is set if (spumoni) @@ -431,16 +431,16 @@ octave_stdout << "\ncsymamd version " << CCOLAMD_MAIN_VERSION << "." << CCOLAMD_SUB_VERSION << ", " << CCOLAMD_DATE << "\n"; - if (knobs [CCOLAMD_DENSE_ROW] >= 0) - octave_stdout << "knobs(1): " << User_knobs (0) + if (knobs[CCOLAMD_DENSE_ROW] >= 0) + octave_stdout << "knobs(1): " << User_knobs(0) << ", rows/cols with > max (16," - << knobs [CCOLAMD_DENSE_ROW] << "*sqrt (size(A,2)))" + << knobs[CCOLAMD_DENSE_ROW] << "*sqrt (size(A,2)))" << " entries removed\n"; else - octave_stdout << "knobs(1): " << User_knobs (0) + octave_stdout << "knobs(1): " << User_knobs(0) << ", no dense rows/cols removed\n"; - if (knobs [CCOLAMD_AGGRESSIVE] != 0) + if (knobs[CCOLAMD_AGGRESSIVE] != 0) octave_stdout << "knobs(2): " << User_knobs(1) << ", aggressive absorption: yes"; else @@ -448,7 +448,7 @@ << ", aggressive absorption: no"; - octave_stdout << "knobs(3): " << User_knobs (2) + octave_stdout << "knobs(3): " << User_knobs(2) << ", statistics and knobs printed\n"; } } @@ -543,7 +543,7 @@ { NDArray out_stats (dim_vector (1, CCOLAMD_STATS)); for (octave_idx_type i = 0 ; i < CCOLAMD_STATS ; i++) - out_stats (i) = stats [i] ; + out_stats(i) = stats[i] ; retval(1) = out_stats; // fix stats (5) and (6), for 1-based information on @@ -562,7 +562,7 @@ { NDArray out_stats (dim_vector (1, CCOLAMD_STATS)); for (octave_idx_type i = 0 ; i < CCOLAMD_STATS ; i++) - out_stats (i) = stats [i] ; + out_stats(i) = stats[i] ; retval(1) = out_stats; // fix stats (5) and (6), for 1-based information on
--- a/src/DLD-FUNCTIONS/colamd.cc +++ b/src/DLD-FUNCTIONS/colamd.cc @@ -63,28 +63,28 @@ if (P) // If P is present then compute Pinv, the inverse of P for (octave_idx_type k = 0 ; k < n ; k++) - Pinv [P [k]] = k ; + Pinv[P[k]] = k ; for (octave_idx_type k = 0 ; k < n ; k++) { // L(k,:) pattern: all nodes reachable in etree from nz in A(0:k-1,k) - Parent [k] = n ; // parent of k is not yet known - Flag [k] = k ; // mark node k as visited - octave_idx_type kk = (P) ? (P [k]) : (k) ; // kth original, or permuted, column - octave_idx_type p2 = cidx [kk+1] ; - for (octave_idx_type p = cidx [kk] ; p < p2 ; p++) + Parent[k] = n ; // parent of k is not yet known + Flag[k] = k ; // mark node k as visited + octave_idx_type kk = (P) ? (P[k]) : (k) ; // kth original, or permuted, column + octave_idx_type p2 = cidx[kk+1] ; + for (octave_idx_type p = cidx[kk] ; p < p2 ; p++) { // A (i,k) is nonzero (original or permuted A) - octave_idx_type i = (Pinv) ? (Pinv [ridx [p]]) : (ridx [p]) ; + octave_idx_type i = (Pinv) ? (Pinv[ridx[p]]) : (ridx[p]) ; if (i < k) { // follow path from i to root of etree, stop at flagged node - for ( ; Flag [i] != k ; i = Parent [i]) + for ( ; Flag[i] != k ; i = Parent[i]) { // find parent of i if not yet determined - if (Parent [i] == n) - Parent [i] = k ; - Flag [i] = k ; // mark i as visited + if (Parent[i] == n) + Parent[i] = k ; + Flag[i] = k ; // mark i as visited } } } @@ -299,11 +299,11 @@ int nel_User_knobs = User_knobs.length (); if (nel_User_knobs > 0) - knobs [COLAMD_DENSE_ROW] = User_knobs (0); + knobs[COLAMD_DENSE_ROW] = User_knobs(0); if (nel_User_knobs > 1) - knobs [COLAMD_DENSE_COL] = User_knobs (1) ; + knobs[COLAMD_DENSE_COL] = User_knobs(1) ; if (nel_User_knobs > 2) - spumoni = static_cast<int> (User_knobs (2)); + spumoni = static_cast<int> (User_knobs(2)); // print knob settings if spumoni is set if (spumoni) @@ -312,19 +312,19 @@ octave_stdout << "\ncolamd version " << COLAMD_MAIN_VERSION << "." << COLAMD_SUB_VERSION << ", " << COLAMD_DATE << ":\n"; - if (knobs [COLAMD_DENSE_ROW] >= 0) + if (knobs[COLAMD_DENSE_ROW] >= 0) octave_stdout << "knobs(1): " << User_knobs (0) << ", rows with > max (16," - << knobs [COLAMD_DENSE_ROW] << "*sqrt (size(A,2)))" + << knobs[COLAMD_DENSE_ROW] << "*sqrt (size(A,2)))" << " entries removed\n"; else octave_stdout << "knobs(1): " << User_knobs (0) << ", only completely dense rows removed\n"; - if (knobs [COLAMD_DENSE_COL] >= 0) + if (knobs[COLAMD_DENSE_COL] >= 0) octave_stdout << "knobs(2): " << User_knobs (1) << ", cols with > max (16," - << knobs [COLAMD_DENSE_COL] << "*sqrt (size(A)))" + << knobs[COLAMD_DENSE_COL] << "*sqrt (size(A)))" << " entries removed\n"; else octave_stdout << "knobs(2): " << User_knobs (1) @@ -380,12 +380,12 @@ // Allocate workspace for colamd OCTAVE_LOCAL_BUFFER (octave_idx_type, p, n_col+1); for (octave_idx_type i = 0; i < n_col+1; i++) - p[i] = cidx [i]; + p[i] = cidx[i]; octave_idx_type Alen = COLAMD_NAME (_recommended) (nnz, n_row, n_col); OCTAVE_LOCAL_BUFFER (octave_idx_type, A, Alen); for (octave_idx_type i = 0; i < nnz; i++) - A[i] = ridx [i]; + A[i] = ridx[i]; // Order the columns (destroys A) OCTAVE_LOCAL_BUFFER (octave_idx_type, stats, COLAMD_STATS); @@ -415,7 +415,7 @@ // return the permutation vector NDArray out_perm (dim_vector (1, n_col)); for (octave_idx_type i = 0; i < n_col; i++) - out_perm(i) = p[colbeg [i]] + 1; + out_perm(i) = p[colbeg[i]] + 1; retval(0) = out_perm; @@ -428,7 +428,7 @@ { NDArray out_stats (dim_vector (1, COLAMD_STATS)); for (octave_idx_type i = 0 ; i < COLAMD_STATS ; i++) - out_stats (i) = stats [i] ; + out_stats(i) = stats[i] ; retval(1) = out_stats; // fix stats (5) and (6), for 1-based information on @@ -534,7 +534,7 @@ int nel_User_knobs = User_knobs.length (); if (nel_User_knobs > 0) - knobs [COLAMD_DENSE_ROW] = User_knobs (COLAMD_DENSE_ROW); + knobs[COLAMD_DENSE_ROW] = User_knobs(COLAMD_DENSE_ROW); if (nel_User_knobs > 1) spumoni = static_cast<int> (User_knobs (1)); } @@ -542,7 +542,7 @@ // print knob settings if spumoni is set if (spumoni > 0) octave_stdout << "symamd: dense row/col fraction: " - << knobs [COLAMD_DENSE_ROW] << std::endl; + << knobs[COLAMD_DENSE_ROW] << std::endl; octave_idx_type n_row, n_col; octave_idx_type *ridx, *cidx; @@ -608,7 +608,7 @@ // return the permutation vector NDArray out_perm (dim_vector (1, n_col)); for (octave_idx_type i = 0; i < n_col; i++) - out_perm(i) = perm[post [i]] + 1; + out_perm(i) = perm[post[i]] + 1; retval(0) = out_perm; @@ -621,7 +621,7 @@ { NDArray out_stats (dim_vector (1, COLAMD_STATS)); for (octave_idx_type i = 0 ; i < COLAMD_STATS ; i++) - out_stats (i) = stats [i] ; + out_stats(i) = stats[i] ; retval(1) = out_stats; // fix stats (5) and (6), for 1-based information on
--- a/src/DLD-FUNCTIONS/spparms.cc +++ b/src/DLD-FUNCTIONS/spparms.cc @@ -126,7 +126,7 @@ std::string str = args(0).string_value (); int len = str.length (); for (int i = 0; i < len; i++) - str [i] = tolower (str [i]); + str[i] = tolower (str[i]); if (str == "defaults") octave_sparse_params::defaults ();
--- a/src/DLD-FUNCTIONS/symbfact.cc +++ b/src/DLD-FUNCTIONS/symbfact.cc @@ -270,7 +270,7 @@ // count the total number of entries in L octave_idx_type lnz = 0 ; for (octave_idx_type j = 0 ; j < n ; j++) - lnz += ColCount [j] ; + lnz += ColCount[j]; // allocate the output matrix L (pattern-only) @@ -281,7 +281,7 @@ for (octave_idx_type j = 0 ; j < n ; j++) { L.xcidx(j) = lnz; - lnz += ColCount [j]; + lnz += ColCount[j]; } L.xcidx(n) = lnz; @@ -302,11 +302,11 @@ { // get the kth row of L and store in the columns of L CHOLMOD_NAME (row_subtree) (A1, A2, k, Parent, R, cm) ; - for (octave_idx_type p = 0 ; p < Rp [1] ; p++) - L.xridx (W [Ri [p]]++) = k ; + for (octave_idx_type p = 0 ; p < Rp[1] ; p++) + L.xridx (W[Ri[p]]++) = k ; // add the diagonal entry - L.xridx (W [k]++) = k ; + L.xridx (W[k]++) = k ; } // free workspace
--- a/src/DLD-FUNCTIONS/symrcm.cc +++ b/src/DLD-FUNCTIONS/symrcm.cc @@ -405,7 +405,7 @@ for (octave_idx_type k = cidx[j]; k < cidx[j + 1]; k++) { OCTAVE_QUIT; - octave_idx_type q = w [ridx[k]]++; + octave_idx_type q = w[ridx[k]]++; ridx2[q] = j; } }
--- a/src/help.cc +++ b/src/help.cc @@ -762,7 +762,7 @@ string_vector retval (lst.size ()); int j = 0; for (map_iter iter = lst.begin (); iter != lst.end (); iter ++) - retval [j++] = iter->first; + retval[j++] = iter->first; return retval; } @@ -1218,11 +1218,11 @@ { const int dir_len = dir.size (); const int filename_len = filename.size (); - const int max_allowed_seps = file_ops::is_dir_sep (dir [dir_len-1]) ? 0 : 1; + const int max_allowed_seps = file_ops::is_dir_sep (dir[dir_len-1]) ? 0 : 1; int num_seps = 0; for (int i = dir_len; i < filename_len; i++) - if (file_ops::is_dir_sep (filename [i])) + if (file_ops::is_dir_sep (filename[i])) num_seps ++; return (num_seps <= max_allowed_seps);
--- a/src/jit-typeinfo.cc +++ b/src/jit-typeinfo.cc @@ -68,7 +68,7 @@ } extern "C" void -octave_jit_print_double (const char *name, double value) +octave_jit_print_scalar (const char *name, double value) { // FIXME: We should avoid allocating a new octave_scalar each time octave_value ov (value); @@ -614,6 +614,13 @@ llvm::verifyFunction (*llvm_function); } +void +jit_function::do_add_mapping (llvm::ExecutionEngine *engine, void *fn) +{ + assert (valid ()); + engine->addGlobalMapping (llvm_function, fn); +} + std::ostream& operator<< (std::ostream& os, const jit_function& fn) { @@ -796,6 +803,7 @@ jit_function any_binary = create_function (jit_convention::external, "octave_jit_binary_any_any", any, binary_op_type, any, any); + any_binary.add_mapping (engine, &octave_jit_binary_any_any); any_binary.mark_can_error (); binary_ops.resize (octave_value::num_binary_ops); for (size_t i = 0; i < octave_value::num_binary_ops; ++i) @@ -827,23 +835,27 @@ // grab any fn = create_function (jit_convention::external, "octave_jit_grab_any", any, any); + fn.add_mapping (engine, &octave_jit_grab_any); grab_fn.add_overload (fn); grab_fn.stash_name ("grab"); // grab matrix fn = create_function (jit_convention::external, "octave_jit_grab_matrix", matrix, matrix); + fn.add_mapping (engine, &octave_jit_grab_matrix); grab_fn.add_overload (fn); // release any fn = create_function (jit_convention::external, "octave_jit_release_any", 0, any); + fn.add_mapping (engine, &octave_jit_release_any); release_fn.add_overload (fn); release_fn.stash_name ("release"); // release matrix fn = create_function (jit_convention::external, "octave_jit_release_matrix", 0, matrix); + fn.add_mapping (engine, &octave_jit_release_matrix); release_fn.add_overload (fn); // release scalar @@ -874,6 +886,7 @@ jit_function gripe_div0 = create_function (jit_convention::external, "gripe_divide_by_zero", 0); + gripe_div0.add_mapping (engine, &gripe_divide_by_zero); gripe_div0.mark_can_error (); // divide is annoying because it might error @@ -914,6 +927,7 @@ fn = create_function (jit_convention::external, "octave_jit_pow_scalar_scalar", complex, scalar, scalar); + fn.add_mapping (engine, &octave_jit_pow_scalar_scalar); binary_ops[octave_value::op_pow].add_overload (fn); binary_ops[octave_value::op_el_pow].add_overload (fn); @@ -975,6 +989,7 @@ jit_function complex_div = create_function (jit_convention::external, "octave_jit_complex_div", complex, complex, complex); + complex_div.add_mapping (engine, &octave_jit_complex_div); complex_div.mark_can_error (); binary_ops[octave_value::op_div].add_overload (fn); binary_ops[octave_value::op_ldiv].add_overload (fn); @@ -986,6 +1001,7 @@ fn = create_function (jit_convention::external, "octave_jit_pow_complex_complex", complex, complex, complex); + fn.add_mapping (engine, &octave_jit_pow_complex_complex); binary_ops[octave_value::op_pow].add_overload (fn); binary_ops[octave_value::op_el_pow].add_overload (fn); @@ -1051,12 +1067,14 @@ fn = create_function (jit_convention::external, "octave_jit_pow_scalar_complex", complex, scalar, complex); + fn.add_mapping (engine, &octave_jit_pow_scalar_complex); binary_ops[octave_value::op_pow].add_overload (fn); binary_ops[octave_value::op_el_pow].add_overload (fn); fn = create_function (jit_convention::external, "octave_jit_pow_complex_scalar", complex, complex, scalar); + fn.add_mapping (engine, &octave_jit_pow_complex_scalar); binary_ops[octave_value::op_pow].add_overload (fn); binary_ops[octave_value::op_el_pow].add_overload (fn); @@ -1069,8 +1087,8 @@ // now for printing functions print_fn.stash_name ("print"); - add_print (any); - add_print (scalar); + add_print (any, reinterpret_cast<void *> (&octave_jit_print_any)); + add_print (scalar, reinterpret_cast<void *> (&octave_jit_print_scalar)); // initialize for loop for_init_fn.stash_name ("for_init"); @@ -1127,6 +1145,7 @@ jit_function gripe_nantl = create_function (jit_convention::external, "octave_jit_gripe_nan_to_logical_conversion", 0); + gripe_nantl.add_mapping (engine, &octave_jit_gripe_nan_to_logical_conversion); gripe_nantl.mark_can_error (); fn = create_function (jit_convention::internal, @@ -1164,6 +1183,7 @@ jit_function compute_nelem = create_function (jit_convention::external, "octave_jit_compute_nelem", index, scalar, scalar, scalar); + compute_nelem.add_mapping (engine, &octave_jit_compute_nelem); fn = create_function (jit_convention::internal, "octave_jit_make_range", range, scalar, scalar, scalar); @@ -1193,10 +1213,12 @@ jit_function ginvalid_index = create_function (jit_convention::external, "octave_jit_ginvalid_index", 0); + ginvalid_index.add_mapping (engine, &octave_jit_ginvalid_index); jit_function gindex_range = create_function (jit_convention::external, "octave_jit_gindex_range", 0, jit_int, jit_int, index, index); + gindex_range.add_mapping (engine, &octave_jit_gindex_range); fn = create_function (jit_convention::internal, "()subsref", scalar, matrix, scalar); @@ -1270,6 +1292,7 @@ jit_function resize_paren_subsasgn = create_function (jit_convention::external, "octave_jit_paren_subsasgn_impl", matrix, index, scalar); + resize_paren_subsasgn.add_mapping (engine, &octave_jit_paren_subsasgn_impl); fn = create_function (jit_convention::internal, "octave_jit_paren_subsasgn", matrix, matrix, scalar, scalar); fn.mark_can_error (); @@ -1338,6 +1361,7 @@ fn = create_function (jit_convention::external, "octave_jit_paren_subsasgn_matrix_range", matrix, matrix, range, scalar); + fn.add_mapping (engine, &octave_jit_paren_subsasgn_matrix_range); fn.mark_can_error (); paren_subsasgn_fn.add_overload (fn); @@ -1349,31 +1373,37 @@ // cast any <- matrix fn = create_function (jit_convention::external, "octave_jit_cast_any_matrix", any, matrix); + fn.add_mapping (engine, &octave_jit_cast_any_matrix); casts[any->type_id ()].add_overload (fn); // cast matrix <- any fn = create_function (jit_convention::external, "octave_jit_cast_matrix_any", matrix, any); + fn.add_mapping (engine, &octave_jit_cast_matrix_any); casts[matrix->type_id ()].add_overload (fn); // cast any <- scalar fn = create_function (jit_convention::external, "octave_jit_cast_any_scalar", any, scalar); + fn.add_mapping (engine, &octave_jit_cast_any_scalar); casts[any->type_id ()].add_overload (fn); // cast scalar <- any fn = create_function (jit_convention::external, "octave_jit_cast_scalar_any", scalar, any); + fn.add_mapping (engine, &octave_jit_cast_scalar_any); casts[scalar->type_id ()].add_overload (fn); // cast any <- complex fn = create_function (jit_convention::external, "octave_jit_cast_any_complex", any, complex); + fn.add_mapping (engine, &octave_jit_cast_any_complex); casts[any->type_id ()].add_overload (fn); // cast complex <- any fn = create_function (jit_convention::external, "octave_jit_cast_complex_any", complex, any); + fn.add_mapping (engine, &octave_jit_cast_complex_any); casts[complex->type_id ()].add_overload (fn); // cast complex <- scalar @@ -1445,12 +1475,13 @@ } void -jit_typeinfo::add_print (jit_type *ty) +jit_typeinfo::add_print (jit_type *ty, void *fptr) { std::stringstream name; name << "octave_jit_print_" << ty->name (); jit_function fn = create_function (jit_convention::external, name.str (), 0, intN (8), ty); + fn.add_mapping (engine, fptr); print_fn.add_overload (fn); } @@ -1546,9 +1577,9 @@ } llvm::Value * -jit_typeinfo::do_insert_error_check (llvm::IRBuilderD& builder) +jit_typeinfo::do_insert_error_check (llvm::IRBuilderD& abuilder) { - return builder.CreateLoad (lerror_state); + return abuilder.CreateLoad (lerror_state); } void
--- a/src/jit-typeinfo.h +++ b/src/jit-typeinfo.h @@ -231,6 +231,12 @@ jit_function (const jit_function& fn); + template <typename T> + void add_mapping (llvm::ExecutionEngine *engine, T fn) + { + do_add_mapping (engine, reinterpret_cast<void *> (fn)); + } + bool valid (void) const { return llvm_function; } std::string name (void) const; @@ -289,6 +295,8 @@ const std::vector<jit_type *>& arguments (void) const { return args; } private: + void do_add_mapping (llvm::ExecutionEngine *engine, void *fn); + llvm::Module *module; llvm::Function *llvm_function; jit_type *mresult; @@ -533,7 +541,7 @@ llvm::Type *llvm_type); - void add_print (jit_type *ty); + void add_print (jit_type *ty, void *fptr); void add_binary_op (jit_type *ty, int op, int llvm_op);
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -1936,7 +1936,7 @@ bool too_large_for_float = false; for (octave_idx_type i = 0; i < nel; i++) { - double tmp = val [i]; + double tmp = val[i]; if (! (xisnan (tmp) || xisinf (tmp)) && fabs (tmp) > FLT_MAX)
--- a/src/pt-eval.cc +++ b/src/pt-eval.cc @@ -1034,6 +1034,11 @@ if (error_state) return; +#if HAVE_LLVM + if (jiter.execute (cmd)) + return; +#endif + unwind_protect frame; frame.protect_var (in_loop_command);
--- a/src/pt-idx.cc +++ b/src/pt-idx.cc @@ -532,7 +532,7 @@ && (tmp.is_matrix_type () || tmp.is_string () || tmp.is_cell ())); - if (i > 0 && type [i-1] == '(') + if (i > 0 && type[i-1] == '(') { octave_value_list pidx = idx.back ();
--- a/src/pt-jit.cc +++ b/src/pt-jit.cc @@ -92,6 +92,10 @@ iter != constants.end (); ++iter) append_users (*iter); + // the entry block terminator may be a regular branch statement + if (entry_block->terminator ()) + push_worklist (entry_block->terminator ()); + // FIXME: Describe algorithm here while (worklist.size ()) { @@ -1475,6 +1479,23 @@ } bool +tree_jit::execute (tree_while_command& cmd) +{ + if (! initialize ()) + return false; + + jit_info *info = cmd.get_info (); + if (! info || ! info->match ()) + { + delete info; + info = new jit_info (*this, cmd); + cmd.stash_info (info); + } + + return info->execute (); +} + +bool tree_jit::initialize (void) { if (engine) @@ -1708,4 +1729,12 @@ %! test_set = gen_test (10000); %! assert (all (vectorized (test_set, 3) == loopy (test_set, 3))); +%!test +%! niter = 1001; +%! i = 0; +%! while (i < niter) +%! i = i + 1; +%! endwhile +%! assert (i == niter); + */
--- a/src/pt-jit.h +++ b/src/pt-jit.h @@ -406,6 +406,8 @@ bool execute (tree_simple_for_command& cmd); + bool execute (tree_while_command& cmd); + llvm::ExecutionEngine *get_engine (void) const { return engine; } llvm::Module *get_module (void) const { return module; }
--- a/src/pt-loop.cc +++ b/src/pt-loop.cc @@ -50,6 +50,9 @@ delete list; delete lead_comm; delete trail_comm; +#ifdef HAVE_LLVM + delete compiled; +#endif } tree_command * @@ -98,7 +101,9 @@ delete list; delete lead_comm; delete trail_comm; +#ifdef HAVE_LLVM delete compiled; +#endif } tree_command *
--- a/src/pt-loop.h +++ b/src/pt-loop.h @@ -47,21 +47,33 @@ tree_while_command (int l = -1, int c = -1) : tree_command (l, c), expr (0), list (0), lead_comm (0), - trail_comm (0) { } + trail_comm (0) +#ifdef HAVE_LLVM + , compiled (0) +#endif + { } tree_while_command (tree_expression *e, octave_comment_list *lc = 0, octave_comment_list *tc = 0, int l = -1, int c = -1) : tree_command (l, c), expr (e), list (0), lead_comm (lc), - trail_comm (tc) { } + trail_comm (tc) +#ifdef HAVE_LLVM + , compiled (0) +#endif + { } tree_while_command (tree_expression *e, tree_statement_list *lst, octave_comment_list *lc = 0, octave_comment_list *tc = 0, int l = -1, int c = -1) : tree_command (l, c), expr (e), list (lst), lead_comm (lc), - trail_comm (tc) { } + trail_comm (tc) +#ifdef HAVE_LLVM + , compiled (0) +#endif + { } ~tree_while_command (void); @@ -78,6 +90,19 @@ void accept (tree_walker& tw); +#ifdef HAVE_LLVM + // some functions use by tree_jit + jit_info *get_info (void) const + { + return compiled; + } + + void stash_info (jit_info *jinfo) + { + compiled = jinfo; + } +#endif + protected: // Expression to test. @@ -94,6 +119,11 @@ private: +#ifdef HAVE_LLVM + // compiled version of the loop + jit_info *compiled; +#endif + // No copying! tree_while_command (const tree_while_command&); @@ -148,7 +178,11 @@ tree_simple_for_command (int l = -1, int c = -1) : tree_command (l, c), parallel (false), lhs (0), expr (0), - maxproc (0), list (0), lead_comm (0), trail_comm (0), compiled (0) { } + maxproc (0), list (0), lead_comm (0), trail_comm (0) +#ifdef HAVE_LLVM + , compiled (0) +#endif + { } tree_simple_for_command (bool parallel_arg, tree_expression *le, tree_expression *re, @@ -159,7 +193,11 @@ int l = -1, int c = -1) : tree_command (l, c), parallel (parallel_arg), lhs (le), expr (re), maxproc (maxproc_arg), list (lst), - lead_comm (lc), trail_comm (tc), compiled (0) { } + lead_comm (lc), trail_comm (tc) +#ifdef HAVE_LLVM + , compiled (0) +#endif + { } ~tree_simple_for_command (void); @@ -182,6 +220,7 @@ void accept (tree_walker& tw); +#ifdef HAVE_LLVM // some functions use by tree_jit jit_info *get_info (void) const { @@ -192,6 +231,7 @@ { compiled = jinfo; } +#endif private: // TRUE means operate in parallel (subject to the value of the
--- a/src/utils.cc +++ b/src/utils.cc @@ -470,7 +470,7 @@ if (fs.exists ()) retval = name; } - else if (len > 2 && name [len - 2] == '.' && name [len - 1] == 'm') + else if (len > 2 && name[len - 2] == '.' && name[len - 1] == 'm') retval = load_path::find_fcn_file (name.substr (0, len-2)); else { @@ -527,8 +527,8 @@ if (fs.exists ()) retval = name; } - else if (len > 4 && name [len - 4] == '.' && name [len - 3] == 'o' - && name [len - 2] == 'c' && name [len - 1] == 't') + else if (len > 4 && name[len - 4] == '.' && name[len - 3] == 'o' + && name[len - 2] == 'c' && name[len - 1] == 't') retval = load_path::find_oct_file (name.substr (0, len-4)); else retval = load_path::find_oct_file (name); @@ -556,8 +556,8 @@ if (fs.exists ()) retval = name; } - else if (len > 4 && name [len - 4] == '.' && name [len - 3] == 'm' - && name [len - 2] == 'e' && name [len - 1] == 'x') + else if (len > 4 && name[len - 4] == '.' && name[len - 3] == 'm' + && name[len - 2] == 'e' && name[len - 1] == 'x') retval = load_path::find_mex_file (name.substr (0, len-4)); else retval = load_path::find_mex_file (name);
--- a/src/variables.cc +++ b/src/variables.cc @@ -1559,7 +1559,7 @@ error ("whos: -file argument must be followed by a file name"); else { - std::string nm = argv [i + 1]; + std::string nm = argv[i + 1]; unwind_protect frame;
--- a/src/zfstream.cc +++ b/src/zfstream.cc @@ -403,7 +403,7 @@ if (buffer_size > 0) { // Allocate internal buffer - buffer = new char_type[buffer_size]; + buffer = new char_type [buffer_size]; // Get area starts empty and will be expanded by underflow as need arises this->setg (buffer, buffer, buffer); // Setup entire internal buffer as put area. @@ -416,7 +416,7 @@ { // Even in "unbuffered" case, (small?) get buffer is still required buffer_size = SMALLBUFSIZE; - buffer = new char_type[buffer_size]; + buffer = new char_type [buffer_size]; this->setg (buffer, buffer, buffer); // "Unbuffered" means no put buffer this->setp (0, 0);