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:
parent
5ab43f8afc
commit
bf3c147f53
@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* 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
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@ -232,10 +232,10 @@ AllocHeap(unsigned int size)
|
||||
YAP_SEG_SIZE *sp;
|
||||
|
||||
#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
|
||||
#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
|
||||
if (size < 6)
|
||||
size = 6;
|
||||
|
20
C/arrays.c
20
C/arrays.c
@ -450,11 +450,16 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
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->NextOfPE = ae->PropsOfAE;
|
||||
INIT_RWLOCK(p->ArRWLock);
|
||||
@ -468,6 +473,8 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
|
||||
int i;
|
||||
|
||||
AllocateStaticArraySpace(p, type, dim);
|
||||
if (p->ValueOfVE.ints == NULL)
|
||||
return p;
|
||||
switch(type) {
|
||||
case array_of_ints:
|
||||
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;
|
||||
}
|
||||
WRITE_UNLOCK(p->ArRWLock);
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -747,11 +755,15 @@ p_create_static_array(void)
|
||||
|
||||
app = (ArrayEntry *) pp;
|
||||
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);
|
||||
} else if (ArrayIsDynamic(app)) {
|
||||
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);
|
||||
} else {
|
||||
Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over dynamic array");
|
||||
|
25
C/bignum.c
25
C/bignum.c
@ -208,6 +208,31 @@ Yap_BigIntOfTerm(Term t)
|
||||
|
||||
#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
|
||||
p_is_bignum(void)
|
||||
{
|
||||
|
@ -2263,9 +2263,9 @@ p_profile_info(void)
|
||||
UNLOCK(pe->StatisticsForPred.lock);
|
||||
return(FALSE);
|
||||
}
|
||||
p[0] = MkIntegerTerm(pe->StatisticsForPred.NOfEntries);
|
||||
p[1] = MkIntegerTerm(pe->StatisticsForPred.NOfHeadSuccesses);
|
||||
p[2] = MkIntegerTerm(pe->StatisticsForPred.NOfRetries);
|
||||
p[0] = Yap_MkULLIntTerm(pe->StatisticsForPred.NOfEntries);
|
||||
p[1] = Yap_MkULLIntTerm(pe->StatisticsForPred.NOfHeadSuccesses);
|
||||
p[2] = Yap_MkULLIntTerm(pe->StatisticsForPred.NOfRetries);
|
||||
UNLOCK(pe->StatisticsForPred.lock);
|
||||
out = Yap_MkApplTerm(Yap_MkFunctor(AtomProfile,3),3,p);
|
||||
return(Yap_unify(ARG3,out));
|
||||
|
8
H/Heap.h
8
H/Heap.h
@ -10,7 +10,7 @@
|
||||
* File: Heap.h *
|
||||
* mods: *
|
||||
* 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 */
|
||||
@ -28,9 +28,9 @@ typedef struct atom_hash_entry {
|
||||
} AtomHashEntry;
|
||||
|
||||
typedef struct reduction_counters {
|
||||
YAP_LONG_LONG reductions;
|
||||
YAP_LONG_LONG reductions_retries;
|
||||
YAP_LONG_LONG retries;
|
||||
YAP_ULONG_LONG reductions;
|
||||
YAP_ULONG_LONG reductions_retries;
|
||||
YAP_ULONG_LONG retries;
|
||||
int reductions_on;
|
||||
int reductions_retries_on;
|
||||
int retries_on;
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: Yap.proto *
|
||||
* mods: *
|
||||
* 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 */
|
||||
@ -93,6 +93,7 @@ void STD_PROTO(Yap_InitAttVarPreds,(void));
|
||||
void STD_PROTO(Yap_InitBBPreds,(void));
|
||||
|
||||
/* bignum.c */
|
||||
Term STD_PROTO(Yap_MkULLIntTerm,(YAP_ULONG_LONG));
|
||||
void STD_PROTO(Yap_InitBigNums,(void));
|
||||
|
||||
/* c_interface.c */
|
||||
|
15
m4/Yap.h.m4
15
m4/Yap.h.m4
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* 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"
|
||||
@ -220,17 +220,12 @@
|
||||
#define SHORT_INTS 0
|
||||
#endif
|
||||
|
||||
#ifdef USE_GMP
|
||||
#ifdef __GNUC__
|
||||
typedef long long int SIGNEDYap_LONG_LONG;
|
||||
typedef unsigned long long int YAP_LONG_LONG;
|
||||
typedef long long int YAP_LONG_LONG;
|
||||
typedef unsigned long long int YAP_ULONG_LONG;
|
||||
#else
|
||||
typedef long int SIGNEDYap_LONG_LONG;
|
||||
typedef unsigned long int YAP_LONG_LONG;
|
||||
#endif
|
||||
#else
|
||||
typedef long int SIGNEDYap_LONG_LONG;
|
||||
typedef unsigned long int YAP_LONG_LONG;
|
||||
typedef long int YAP_LONG_LONG;
|
||||
typedef unsigned long int YAP_ULONG_LONG;
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
|
@ -196,9 +196,9 @@ typedef struct {
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
lockvar lock; /* a simple lock to protect this entry */
|
||||
#endif
|
||||
Int NOfEntries; /* nbr of times head unification succeeded*/
|
||||
Int NOfHeadSuccesses; /* nbr of times head unification succeeded*/
|
||||
Int NOfRetries; /* nbr of times a clause for the pred
|
||||
YAP_ULONG_LONG NOfEntries; /* nbr of times head unification succeeded*/
|
||||
YAP_ULONG_LONG NOfHeadSuccesses; /* nbr of times head unification succeeded*/
|
||||
YAP_ULONG_LONG NOfRetries; /* nbr of times a clause for the pred
|
||||
was retried */
|
||||
} profile_data;
|
||||
|
||||
|
Reference in New Issue
Block a user