"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Core/pdl.h.PL" between
PDL-2.074.tar.gz and PDL-2.075.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

pdl.h.PL  (PDL-2.074):pdl.h.PL  (PDL-2.075)
skipping to change at line 95 skipping to change at line 95
ctype ppsym; ctype ppsym;
PDL_TYPELIST_ALL(X) PDL_TYPELIST_ALL(X)
#undef X #undef X
} PDL_Value; } PDL_Value;
typedef struct { typedef struct {
pdl_datatypes type; pdl_datatypes type;
PDL_Value value; PDL_Value value;
} PDL_Anyval; } PDL_Anyval;
#include "pdlthread.h" #define PDL_CHKMAGIC_GENERAL(it,this_magic,type) \
if((it)->magicno != this_magic) \
return pdl_make_error(PDL_EFATAL, \
"INVALID " type " MAGICNO, got hex=%p (%lu)%s\n", \
it,(unsigned long)((it)->magicno), \
((it)->magicno) == PDL_CLEARED_MAGICNO ? " (cleared)" : "" \
); \
else (void)0
#define PDL_CLEARED_MAGICNO 0x99876134 /* value once "cleared" */
#define PDL_CLRMAGIC(it) (it)->magicno = PDL_CLEARED_MAGICNO
#include "pdlbroadcast.h"
/* Auto-PThreading (i.e. multi-threading) settings for PDL functions */ /* Auto-PThreading (i.e. multi-threading) settings for PDL functions */
/* Target number of pthreads: Actual will be this number or less. /* Target number of pthreads: Actual will be this number or less.
A 0 here means no pthreading */ A 0 here means no pthreading */
extern int pdl_autopthread_targ; extern int pdl_autopthread_targ;
/* Actual number of pthreads: This is the number of pthreads created for the la st /* Actual number of pthreads: This is the number of pthreads created for the la st
operation where pthreading was used operation where pthreading was used
A 0 here means no pthreading */ A 0 here means no pthreading */
extern int pdl_autopthread_actual; extern int pdl_autopthread_actual;
skipping to change at line 235 skipping to change at line 246
* include perl.h in C code which just needs the pdl data. * include perl.h in C code which just needs the pdl data.
* *
* We start with the meanings of the pdl.flags bitmapped flagset, * We start with the meanings of the pdl.flags bitmapped flagset,
* continue with a prerequisite "trans" structure that represents * continue with a prerequisite "trans" structure that represents
* transformations between linked PDLs, and finish withthe PD * transformations between linked PDLs, and finish withthe PD
* structure itself. * structure itself.
*/ */
#define PDL_NDIMS 6 /* Number of dims[] to preallocate */ #define PDL_NDIMS 6 /* Number of dims[] to preallocate */
#define PDL_NCHILDREN 8 /* Number of trans_children ptrs to preallocate */ #define PDL_NCHILDREN 8 /* Number of trans_children ptrs to preallocate */
#define PDL_NTHREADIDS 4 /* Number of different threadids/pdl to preallocate */ #define PDL_NBROADCASTIDS 4 /* Number of different broadcastids/pdl to prealloca te */
/* Constants for pdl.state - not all combinations make sense */ /* Constants for pdl.state - not all combinations make sense */
/* data allocated for this pdl. this implies that the data */ /* data allocated for this pdl. this implies that the data */
/* is up to date if !PDL_PARENTCHANGED */ /* is up to date if !PDL_PARENTCHANGED */
#define PDL_ALLOCATED 0x0001 #define PDL_ALLOCATED 0x0001
/* Parent data has been altered without changing this pdl */ /* Parent data has been altered without changing this pdl */
#define PDL_PARENTDATACHANGED 0x0002 #define PDL_PARENTDATACHANGED 0x0002
/* Parent dims or incs has been altered without changing this pdl. */ /* Parent dims or incs has been altered without changing this pdl. */
#define PDL_PARENTDIMSCHANGED 0x0004 #define PDL_PARENTDIMSCHANGED 0x0004
skipping to change at line 307 skipping to change at line 318
* *
* Transformation structure * Transformation structure
* *
* The structure is general enough to deal with functional transforms * The structure is general enough to deal with functional transforms
* (which were originally intended) but only slices and retype transforms * (which were originally intended) but only slices and retype transforms
* were implemented. * were implemented.
* *
*/ */
/* Transformation flags */ /* Transformation flags */
#define PDL_TRANS_DO_THREAD 0x0001 #define PDL_TRANS_DO_BROADCAST 0x0001
#define PDL_TRANS_BADPROCESS 0x0002 #define PDL_TRANS_BADPROCESS 0x0002
#define PDL_TRANS_BADIGNORE 0x0004 #define PDL_TRANS_BADIGNORE 0x0004
#define PDL_TRANS_NO_PARALLEL 0x0008 #define PDL_TRANS_NO_PARALLEL 0x0008
#define PDL_LIST_FLAGS_PDLVTABLE(X) \ #define PDL_LIST_FLAGS_PDLVTABLE(X) \
X(PDL_TRANS_DO_THREAD) \ X(PDL_TRANS_DO_BROADCAST) \
X(PDL_TRANS_BADPROCESS) \ X(PDL_TRANS_BADPROCESS) \
X(PDL_TRANS_BADIGNORE) \ X(PDL_TRANS_BADIGNORE) \
X(PDL_TRANS_NO_PARALLEL) X(PDL_TRANS_NO_PARALLEL)
/* Transpdl flags */ /* Transpdl flags */
#define PDL_TPDL_VAFFINE_OK 0x01 #define PDL_TPDL_VAFFINE_OK 0x01
typedef struct pdl_trans pdl_trans; typedef struct pdl_trans pdl_trans;
typedef enum { typedef enum {
skipping to change at line 429 skipping to change at line 440
// initial piece. These structures can contain multiple pdl* elements in them. // initial piece. These structures can contain multiple pdl* elements in them.
// Thus pdl_trans itself ends with a flexible pdl*[] array, which can be used to // Thus pdl_trans itself ends with a flexible pdl*[] array, which can be used to
// reference any number of pdl objects. As a result pdl_trans itself can NOT be // reference any number of pdl objects. As a result pdl_trans itself can NOT be
// instantiated // instantiated
#define PDL_TRANS_START_COMMON \ #define PDL_TRANS_START_COMMON \
unsigned int magicno; \ unsigned int magicno; \
short flags; \ short flags; \
pdl_transvtable *vtable; \ pdl_transvtable *vtable; \
int bvalflag; \ int bvalflag; \
pdl_thread pdlthread; \ pdl_broadcast broadcast; \
PDL_Indx *ind_sizes; \ PDL_Indx *ind_sizes; \
PDL_Indx *inc_sizes; \ PDL_Indx *inc_sizes; \
char dims_redone; \ char dims_redone; \
PDL_Indx *incs; PDL_Indx offs; /* only used for affine */ \ PDL_Indx *incs; PDL_Indx offs; /* only used for affine */ \
void *params; \ void *params; \
pdl_datatypes __datatype pdl_datatypes __datatype
#define PDL_TRANS_START(np) \ #define PDL_TRANS_START(np) \
PDL_TRANS_START_COMMON; \ PDL_TRANS_START_COMMON; \
/* The pdls involved in the transformation */ \ /* The pdls involved in the transformation */ \
pdl *pdls[np] pdl *pdls[np]
#define PDL_TRANS_START_FLEXIBLE() \ #define PDL_TRANS_START_FLEXIBLE() \
PDL_TRANS_START_COMMON; \ PDL_TRANS_START_COMMON; \
/* The pdls involved in the transformation */ \ /* The pdls involved in the transformation */ \
pdl *pdls[] pdl *pdls[]
#define PDL_CHKMAGIC_GENERAL(it,this_magic,type) if((it)->magicno != this_magic)
return pdl_make_error(PDL_EFATAL, "INVALID " #type "MAGIC NO 0x%p %d%s\n",it,(i
nt)((it)->magicno), ((it)->magicno) == PDL_CLEARED_MAGICNO ? " (cleared)" : "");
else (void)0
#define PDL_TR_MAGICNO 0x91827364 #define PDL_TR_MAGICNO 0x91827364
#define PDL_TR_SETMAGIC(it) it->magicno = PDL_TR_MAGICNO #define PDL_TR_CHKMAGIC(it) PDL_CHKMAGIC_GENERAL(it, PDL_TR_MAGICNO, "TRANS")
#define PDL_TR_CLRMAGIC(it) it->magicno = PDL_CLEARED_MAGICNO #define PDL_TR_SETMAGIC(it) (it)->magicno = PDL_TR_MAGICNO
#define PDL_TR_CHKMAGIC(it) PDL_CHKMAGIC_GENERAL(it, PDL_TR_MAGICNO, "TRANS ")
// This is a generic parent of all the trans structures. It is a flexible array // This is a generic parent of all the trans structures. It is a flexible array
// (can store an arbitrary number of pdl objects). Thus this can NOT be // (can store an arbitrary number of pdl objects). Thus this can NOT be
// instantiated, only "child" structures can // instantiated, only "child" structures can
struct pdl_trans { struct pdl_trans {
PDL_TRANS_START_FLEXIBLE(); PDL_TRANS_START_FLEXIBLE();
} ; } ;
typedef struct pdl_vaffine { typedef struct pdl_vaffine {
PDL_TRANS_START(2); PDL_TRANS_START(2);
skipping to change at line 503 skipping to change at line 511
-MInline=C,'size_t f() { return sizeof(struct pdl); }' -e 'die f()' -MInline=C,'size_t f() { return sizeof(struct pdl); }' -e 'die f()'
* *
* The 'sv', 'datasv', and 'hdrsv' fields are all void * to avoid having to * The 'sv', 'datasv', and 'hdrsv' fields are all void * to avoid having to
* load perl.h for C codes that only use PDLs and not the Perl API. * load perl.h for C codes that only use PDLs and not the Perl API.
* *
* Similarly, the 'magic' field is void * to avoid having to typedef pdl_magic * Similarly, the 'magic' field is void * to avoid having to typedef pdl_magic
* here -- it is declared in "pdl_magic.h". * here -- it is declared in "pdl_magic.h".
*/ */
#define PDL_MAGICNO 0x24645399 #define PDL_MAGICNO 0x24645399
#define PDL_CLEARED_MAGICNO 0x99876134 /* value once "cleared" */ #define PDL_CHKMAGIC(it) PDL_CHKMAGIC_GENERAL(it,PDL_MAGICNO,"PDL")
#define PDL_CHKMAGIC(it) PDL_CHKMAGIC_GENERAL(it,PDL_MAGICNO,"") #define PDL_SETMAGIC(it) (it)->magicno = PDL_MAGICNO
struct pdl { struct pdl {
unsigned long magicno; /* Always stores PDL_MAGICNO as a sanity check */ unsigned long magicno; /* Always stores PDL_MAGICNO as a sanity check */
/* This is first so most pointer accesses to wrong type are caught */ /* This is first so most pointer accesses to wrong type are caught */
int state; /* What's in this pdl */ int state; /* What's in this pdl */
pdl_trans *trans_parent; /* Opaque pointer to internals of transformation fro m pdl_trans *trans_parent; /* Opaque pointer to internals of transformation fro m
parent */ parent */
pdl_vaffine *vafftrans; /* pointer to vaffine transformation pdl_vaffine *vafftrans; /* pointer to vaffine transformation
skipping to change at line 535 skipping to change at line 543
void *data; /* Pointer to actual data (in SV), or NULL if we have no data */ void *data; /* Pointer to actual data (in SV), or NULL if we have no data */
PDL_Anyval badvalue; /* BAD value is stored as a PDL_Anyval for portability * / PDL_Anyval badvalue; /* BAD value is stored as a PDL_Anyval for portability * /
int has_badvalue; /* whether this pdl has non-default badval */ int has_badvalue; /* whether this pdl has non-default badval */
PDL_Indx nvals; /* Real number of elements (not quite nelem in case of dummy) */ PDL_Indx nvals; /* Real number of elements (not quite nelem in case of dummy) */
PDL_Indx nbytes; /* number of bytes allocated in data */ PDL_Indx nbytes; /* number of bytes allocated in data */
pdl_datatypes datatype; /* One of the usual suspects (PDL_L, PDL_D, etc.) */ pdl_datatypes datatype; /* One of the usual suspects (PDL_L, PDL_D, etc.) */
PDL_Indx *dims; /* Array of data dimensions - could point below or to an allocated array */ PDL_Indx *dims; /* Array of data dimensions - could point below or to an allocated array */
PDL_Indx *dimincs; /* Array of data default increments, aka strides throu gh memory for each dim (0 for dummies) */ PDL_Indx *dimincs; /* Array of data default increments, aka strides throu gh memory for each dim (0 for dummies) */
PDL_Indx ndims; /* Number of data dimensions in dims and dimincs */ PDL_Indx ndims; /* Number of data dimensions in dims and dimincs */
PDL_Indx *threadids; /* Starting index of the thread index set n */ PDL_Indx *broadcastids; /* Starting index of the broadcast index set n */
PDL_Indx nthreadids; PDL_Indx nbroadcastids;
pdl_trans_children trans_children; pdl_trans_children trans_children;
PDL_Indx def_dims[PDL_NDIMS]; /* Preallocated space for efficiency */ PDL_Indx def_dims[PDL_NDIMS]; /* Preallocated space for efficiency */
PDL_Indx def_dimincs[PDL_NDIMS]; /* Preallocated space for efficiency */ PDL_Indx def_dimincs[PDL_NDIMS]; /* Preallocated space for efficiency */
PDL_Indx def_threadids[PDL_NTHREADIDS]; PDL_Indx def_broadcastids[PDL_NBROADCASTIDS];
struct pdl_magic *magic; struct pdl_magic *magic;
void *hdrsv; /* "header", settable from Perl */ void *hdrsv; /* "header", settable from Perl */
}; };
typedef struct pdl_slice_args { typedef struct pdl_slice_args {
PDL_Indx start; /* maps to start index of slice range (inclusive) */ PDL_Indx start; /* maps to start index of slice range (inclusive) */
PDL_Indx end; /* maps to end index of slice range (inclusive) */ PDL_Indx end; /* maps to end index of slice range (inclusive) */
PDL_Indx inc; /* maps to increment of slice range */ PDL_Indx inc; /* maps to increment of slice range */
skipping to change at line 587 skipping to change at line 595
#define PDLMIN(a,b) ((a) < (b) ? (a) : (b)) #define PDLMIN(a,b) ((a) < (b) ? (a) : (b))
/*************** /***************
* Some macros to guard against dataflow infinite recursion. * Some macros to guard against dataflow infinite recursion.
*/ */
#define DECL_RECURSE_GUARD static int __nrec=0; #define DECL_RECURSE_GUARD static int __nrec=0;
#define START_RECURSE_GUARD __nrec++; if(__nrec > 1000) {__nrec=0; return pdl_ma ke_error_simple(PDL_EUSERERROR, "PDL:Internal Error: data structure recursion li mit exceeded (max 1000 levels)\n\tThis could mean that you have found an infinit e-recursion error in PDL, or\n\tthat you are building data structures with very long dataflow dependency\n\tchains. You may want to try using sever() to break the dependency.\n");} #define START_RECURSE_GUARD __nrec++; if(__nrec > 1000) {__nrec=0; return pdl_ma ke_error_simple(PDL_EUSERERROR, "PDL:Internal Error: data structure recursion li mit exceeded (max 1000 levels)\n\tThis could mean that you have found an infinit e-recursion error in PDL, or\n\tthat you are building data structures with very long dataflow dependency\n\tchains. You may want to try using sever() to break the dependency.\n");}
#define ABORT_RECURSE_GUARD __nrec=0; #define ABORT_RECURSE_GUARD __nrec=0;
#define END_RECURSE_GUARD __nrec--; #define END_RECURSE_GUARD __nrec--;
#define PDL_RETERROR(rv, expr) \ #define PDL_RETERROR2(rv, expr, iferr) \
do { rv = expr; if (rv.error) return rv; } while (0) do { rv = expr; if (rv.error) { iferr } } while (0)
#define PDL_RETERROR(rv, expr) PDL_RETERROR2(rv, expr, return rv;)
#define PDL_ACCUMERROR(rv, expr) rv = pdl_error_accumulate(rv, expr)
#define PDL_ENSURE_ALLOCATED(it) \ #define PDL_ENSURE_ALLOCATED(it) \
if (!(it->state & PDL_ALLOCATED)) { \ if (!(it->state & PDL_ALLOCATED)) { \
PDL_RETERROR(PDL_err, pdl_allocdata(it)); \ PDL_RETERROR(PDL_err, pdl_allocdata(it)); \
} }
/* for use with PDL_TYPELIST_REAL */ /* for use with PDL_TYPELIST_REAL */
#define PDL_QSORT(symbol, ctype, ppsym, ...) \ #define PDL_QSORT(symbol, ctype, ppsym, ...) \
static inline void qsort_ ## ppsym(ctype* xx, PDL_Indx a, PDL_Indx b) { \ static inline void qsort_ ## ppsym(ctype* xx, PDL_Indx a, PDL_Indx b) { \
PDL_Indx i,j; \ PDL_Indx i,j; \
skipping to change at line 619 skipping to change at line 629
i++; j--; \ i++; j--; \
} \ } \
} while (i <= j); \ } while (i <= j); \
if (a < j) \ if (a < j) \
qsort_ ## ppsym(xx,a,j); \ qsort_ ## ppsym(xx,a,j); \
if (i < b) \ if (i < b) \
qsort_ ## ppsym(xx,i,b); \ qsort_ ## ppsym(xx,i,b); \
} }
#define PDL_EXPAND(...) __VA_ARGS__ #define PDL_EXPAND(...) __VA_ARGS__
#define PDL_THREADLOOP_START(funcName, thr, vtable, ptrStep1, ptrStep2, ptrStep3 #define PDL_BROADCASTLOOP_START(funcName, brc, vtable, ptrStep1, ptrStep2, ptrSt
) \ ep3) \
__thrloopval = PDL->startthreadloop(&(thr),(vtable)->funcName, __privtrans, &P __brcloopval = PDL->startbroadcastloop(&(brc),(vtable)->funcName, __privtrans,
DL_err); \ &PDL_err); \
if (PDL_err.error) return PDL_err; \ if (PDL_err.error) return PDL_err; \
if ( __thrloopval < 0 ) return PDL->make_error_simple(PDL_EFATAL, "Error start if ( __brcloopval < 0 ) return PDL->make_error_simple(PDL_EFATAL, "Error start
ing threadloop"); \ ing broadcastloop"); \
if ( __thrloopval ) return PDL_err; \ if ( __brcloopval ) return PDL_err; \
do { \ do { \
PDL_Indx *__tdims = PDL->get_threaddims(&(thr)); \ PDL_Indx *__tdims = PDL->get_broadcastdims(&(brc)); \
if (!__tdims) return PDL->make_error_simple(PDL_EFATAL, "Error in get_thread if (!__tdims) return PDL->make_error_simple(PDL_EFATAL, "Error in get_broadc
dims"); \ astdims"); \
register PDL_Indx __tdims0 = __tdims[0]; \ register PDL_Indx __tdims0 = __tdims[0]; \
register PDL_Indx __tdims1 = __tdims[1]; \ register PDL_Indx __tdims1 = __tdims[1]; \
register PDL_Indx *__offsp = PDL->get_threadoffsp(&(thr)); \ register PDL_Indx *__offsp = PDL->get_threadoffsp(&(brc)); \
if (!__offsp ) return PDL->make_error_simple(PDL_EFATAL, "Error in get_threa doffsp"); \ if (!__offsp ) return PDL->make_error_simple(PDL_EFATAL, "Error in get_threa doffsp"); \
PDL_COMMENT("incs are each pdl's stride, declared at func start") \ PDL_COMMENT("incs are each pdl's stride, declared at func start") \
PDL_COMMENT("offs are each pthread's starting offset into each pdl") \ PDL_COMMENT("offs are each pthread's starting offset into each pdl") \
ptrStep1 \ ptrStep1 \
for( __tind1 = 0 ; \ for( __tind1 = 0 ; \
__tind1 < __tdims1 ; \ __tind1 < __tdims1 ; \
__tind1++ \ __tind1++ \
PDL_COMMENT("step by tinc1, undoing inner-loop of tinc0*tdims0") \ PDL_COMMENT("step by tinc1, undoing inner-loop of tinc0*tdims0") \
PDL_EXPAND ptrStep2 \ PDL_EXPAND ptrStep2 \
) \ ) \
{ \ { \
for( __tind0 = 0 ; \ for( __tind0 = 0 ; \
__tind0 < __tdims0 ; \ __tind0 < __tdims0 ; \
__tind0++ \ __tind0++ \
PDL_EXPAND ptrStep3 \ PDL_EXPAND ptrStep3 \
) { \ ) { \
PDL_COMMENT("This is the tightest threadloop. Make sure inside is optima PDL_COMMENT("This is the tightest loop. Make sure inside is optimal.")
l.") #define PDL_BROADCASTLOOP_END(brc, ptrStep1) \
#define PDL_THREADLOOP_END(thr, ptrStep1) \
} \ } \
} \ } \
PDL_COMMENT("undo outer-loop of tinc1*tdims1, and original per-pthread offse t") \ PDL_COMMENT("undo outer-loop of tinc1*tdims1, and original per-pthread offse t") \
ptrStep1 \ ptrStep1 \
__thrloopval = PDL->iterthreadloop(&(thr),2); \ __brcloopval = PDL->iterbroadcastloop(&(brc),2); \
if ( __thrloopval < 0 ) return PDL->make_error_simple(PDL_EFATAL, "Error in if ( __brcloopval < 0 ) return PDL->make_error_simple(PDL_EFATAL, "Error in
iterthreadloop"); \ iterbroadcastloop"); \
} while(__thrloopval); } while(__brcloopval);
/* __PDL_H */ /* __PDL_H */
#endif #endif
!NO!SUBS! !NO!SUBS!
 End of changes. 17 change blocks. 
38 lines changed or deleted 44 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)