support long long for profiling counters. Requires better support for LL

in Yap code (only for __GNUC__ right now).


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@802 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2003-03-20 15:10:18 +00:00
parent 5ab43f8afc
commit bf3c147f53
8 changed files with 61 additions and 28 deletions

View File

@ -12,7 +12,7 @@
* Last rev: * * Last rev: *
* mods: * * mods: *
* comments: allocating space * * comments: allocating space *
* version:$Id: alloc.c,v 1.31 2003-01-29 14:47:07 vsc Exp $ * * version:$Id: alloc.c,v 1.32 2003-03-20 15:10:13 vsc Exp $ *
*************************************************************************/ *************************************************************************/
#ifdef SCCS #ifdef SCCS
static char SccsId[] = "%W% %G%"; static char SccsId[] = "%W% %G%";
@ -232,10 +232,10 @@ AllocHeap(unsigned int size)
YAP_SEG_SIZE *sp; YAP_SEG_SIZE *sp;
#if SIZEOF_INT_P==4 #if SIZEOF_INT_P==4
size = (((size + 7) & 0xffffff8) >> 2) + 2; /* size in dwords + 2 */ size = (((size + 7) & 0xfffffff8L) >> 2) + 2; /* size in dwords + 2 */
#endif #endif
#if SIZEOF_INT_P==8 #if SIZEOF_INT_P==8
size = (((size + 7) & 0xffffff8) >> 3) + 2; /* size in dwords + 2 */ size = (((size + 7) & 0xfffffffffffffff8LL) >> 3) + 2; /* size in dwords + 2 */
#endif #endif
if (size < 6) if (size < 6)
size = 6; size = 6;

View File

@ -450,11 +450,16 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra
} }
/* ae and p are assumed to be locked, if they exist */ /* ae and p are assumed to be locked, if they exist */
static void static StaticArrayEntry *
CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR start_addr, StaticArrayEntry *p) CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR start_addr, StaticArrayEntry *p)
{ {
if (EndOfPAEntr(p)) { if (EndOfPAEntr(p)) {
p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p)); while ((p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p))) == NULL) {
if (!Yap_growheap(FALSE)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return NULL;
}
}
p->KindOfPE = ArrayProperty; p->KindOfPE = ArrayProperty;
p->NextOfPE = ae->PropsOfAE; p->NextOfPE = ae->PropsOfAE;
INIT_RWLOCK(p->ArRWLock); INIT_RWLOCK(p->ArRWLock);
@ -468,6 +473,8 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
int i; int i;
AllocateStaticArraySpace(p, type, dim); AllocateStaticArraySpace(p, type, dim);
if (p->ValueOfVE.ints == NULL)
return p;
switch(type) { switch(type) {
case array_of_ints: case array_of_ints:
for (i = 0; i < dim; i++) for (i = 0; i < dim; i++)
@ -504,6 +511,7 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
p->ValueOfVE.chars = (char *)start_addr; p->ValueOfVE.chars = (char *)start_addr;
} }
WRITE_UNLOCK(p->ArRWLock); WRITE_UNLOCK(p->ArRWLock);
return p;
} }
static void static void
@ -747,11 +755,15 @@ p_create_static_array(void)
app = (ArrayEntry *) pp; app = (ArrayEntry *) pp;
if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) { if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) {
CreateStaticArray(ae, size, props, NULL, pp); pp = CreateStaticArray(ae, size, props, NULL, pp);
if (pp == NULL || pp->ValueOfVE.ints == NULL)
return(FALSE);
return (TRUE); return (TRUE);
} else if (ArrayIsDynamic(app)) { } else if (ArrayIsDynamic(app)) {
if (IsVarTerm(app->ValueOfVE) && IsUnboundVar(app->ValueOfVE)) { if (IsVarTerm(app->ValueOfVE) && IsUnboundVar(app->ValueOfVE)) {
CreateStaticArray(ae, size, props, NULL, pp); pp = CreateStaticArray(ae, size, props, NULL, pp);
if (pp == NULL)
return(FALSE);
return (TRUE); return (TRUE);
} else { } else {
Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over dynamic array"); Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over dynamic array");

View File

@ -208,6 +208,31 @@ Yap_BigIntOfTerm(Term t)
#endif #endif
Term
Yap_MkULLIntTerm(YAP_ULONG_LONG n)
{
#ifdef __GNUC__
if (n != (UInt)n) {
#if USE_GMP
/* try to scan it as a bignum */
MP_INT *new = Yap_PreAllocBigNum();
mpz_init(new);
mpz_set_ui(new, n>>32);
mpz_mul_2exp(new, new, 32);
mpz_add_ui(new, new, (UInt)n);
return(Yap_MkBigIntTerm(new));
#else
return(MkFloatTerm(n));
#endif
} else {
return MkIntegerTerm(n);
}
#else
return MkIntegerTerm(n);
#endif
}
static Int static Int
p_is_bignum(void) p_is_bignum(void)
{ {

View File

@ -2263,9 +2263,9 @@ p_profile_info(void)
UNLOCK(pe->StatisticsForPred.lock); UNLOCK(pe->StatisticsForPred.lock);
return(FALSE); return(FALSE);
} }
p[0] = MkIntegerTerm(pe->StatisticsForPred.NOfEntries); p[0] = Yap_MkULLIntTerm(pe->StatisticsForPred.NOfEntries);
p[1] = MkIntegerTerm(pe->StatisticsForPred.NOfHeadSuccesses); p[1] = Yap_MkULLIntTerm(pe->StatisticsForPred.NOfHeadSuccesses);
p[2] = MkIntegerTerm(pe->StatisticsForPred.NOfRetries); p[2] = Yap_MkULLIntTerm(pe->StatisticsForPred.NOfRetries);
UNLOCK(pe->StatisticsForPred.lock); UNLOCK(pe->StatisticsForPred.lock);
out = Yap_MkApplTerm(Yap_MkFunctor(AtomProfile,3),3,p); out = Yap_MkApplTerm(Yap_MkFunctor(AtomProfile,3),3,p);
return(Yap_unify(ARG3,out)); return(Yap_unify(ARG3,out));

View File

@ -10,7 +10,7 @@
* File: Heap.h * * File: Heap.h *
* mods: * * mods: *
* comments: Heap Init Structure * * comments: Heap Init Structure *
* version: $Id: Heap.h,v 1.38 2003-02-24 11:00:58 vsc Exp $ * * version: $Id: Heap.h,v 1.39 2003-03-20 15:10:16 vsc Exp $ *
*************************************************************************/ *************************************************************************/
/* information that can be stored in Code Space */ /* information that can be stored in Code Space */
@ -28,9 +28,9 @@ typedef struct atom_hash_entry {
} AtomHashEntry; } AtomHashEntry;
typedef struct reduction_counters { typedef struct reduction_counters {
YAP_LONG_LONG reductions; YAP_ULONG_LONG reductions;
YAP_LONG_LONG reductions_retries; YAP_ULONG_LONG reductions_retries;
YAP_LONG_LONG retries; YAP_ULONG_LONG retries;
int reductions_on; int reductions_on;
int reductions_retries_on; int reductions_retries_on;
int retries_on; int retries_on;

View File

@ -10,7 +10,7 @@
* File: Yap.proto * * File: Yap.proto *
* mods: * * mods: *
* comments: Function declarations for YAP * * comments: Function declarations for YAP *
* version: $Id: Yapproto.h,v 1.32 2003-01-13 14:02:50 vsc Exp $ * * version: $Id: Yapproto.h,v 1.33 2003-03-20 15:10:17 vsc Exp $ *
*************************************************************************/ *************************************************************************/
/* prototype file for Yap */ /* prototype file for Yap */
@ -93,6 +93,7 @@ void STD_PROTO(Yap_InitAttVarPreds,(void));
void STD_PROTO(Yap_InitBBPreds,(void)); void STD_PROTO(Yap_InitBBPreds,(void));
/* bignum.c */ /* bignum.c */
Term STD_PROTO(Yap_MkULLIntTerm,(YAP_ULONG_LONG));
void STD_PROTO(Yap_InitBigNums,(void)); void STD_PROTO(Yap_InitBigNums,(void));
/* c_interface.c */ /* c_interface.c */

View File

@ -10,7 +10,7 @@
* File: Yap.h.m4 * * File: Yap.h.m4 *
* mods: * * mods: *
* comments: main header file for YAP * * comments: main header file for YAP *
* version: $Id: Yap.h.m4,v 1.42 2003-03-13 15:34:32 rslopes Exp $ * * version: $Id: Yap.h.m4,v 1.43 2003-03-20 15:10:17 vsc Exp $ *
*************************************************************************/ *************************************************************************/
#include "config.h" #include "config.h"
@ -220,17 +220,12 @@
#define SHORT_INTS 0 #define SHORT_INTS 0
#endif #endif
#ifdef USE_GMP
#ifdef __GNUC__ #ifdef __GNUC__
typedef long long int SIGNEDYap_LONG_LONG; typedef long long int YAP_LONG_LONG;
typedef unsigned long long int YAP_LONG_LONG; typedef unsigned long long int YAP_ULONG_LONG;
#else #else
typedef long int SIGNEDYap_LONG_LONG; typedef long int YAP_LONG_LONG;
typedef unsigned long int YAP_LONG_LONG; typedef unsigned long int YAP_ULONG_LONG;
#endif
#else
typedef long int SIGNEDYap_LONG_LONG;
typedef unsigned long int YAP_LONG_LONG;
#endif #endif
#if DEBUG #if DEBUG

View File

@ -196,9 +196,9 @@ typedef struct {
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
lockvar lock; /* a simple lock to protect this entry */ lockvar lock; /* a simple lock to protect this entry */
#endif #endif
Int NOfEntries; /* nbr of times head unification succeeded*/ YAP_ULONG_LONG NOfEntries; /* nbr of times head unification succeeded*/
Int NOfHeadSuccesses; /* nbr of times head unification succeeded*/ YAP_ULONG_LONG NOfHeadSuccesses; /* nbr of times head unification succeeded*/
Int NOfRetries; /* nbr of times a clause for the pred YAP_ULONG_LONG NOfRetries; /* nbr of times a clause for the pred
was retried */ was retried */
} profile_data; } profile_data;