Skip to content

Commit

Permalink
Builds, but default ecolab model crashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
highperformancecoder committed Jul 21, 2024
1 parent 72048d8 commit 1f05534
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 184 deletions.
20 changes: 6 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,6 @@ endif
echo AQUA=$(AQUA)>>$(MCFG)
echo MAC_OSX_TK=$(MAC_OSX_TK)>>$(MCFG)

#lib/libecolab$(ECOLIBS_EXT).so: lib $(OBJS)
# -cd graphcode; $(GRAPHCODE_MAKE) MAP=vmap libgraphcode.a
# -cd graphcode; $(GRAPHCODE_MAKE) MAP=hmap libgraphcode.a
# -cp -f graphcode/*.h graphcode/vmap graphcode/hmap include
# $(LINK) $(FLAGS) -shared $(OBJS) graphcode/*.hmap graphcode/*.vmap -o $@

#ecolab-libs: lib bin $(CLASSDESC) include/nauty_sizes.h
ecolab-libs: lib bin
$(MAKE) $(UTILS)
$(MAKE) $(ELIBS)
Expand Down Expand Up @@ -195,14 +188,13 @@ bin:

lib/libecolab$(ECOLIBS_EXT).a: $(OBJS) $(LIBMODS)
# build graphcode objects
-cd graphcode; $(GRAPHCODE_MAKE) MAP=vmap libgraphcode.a
-cd graphcode; $(GRAPHCODE_MAKE) MAP=hmap libgraphcode.a
-cp -f graphcode/*.h graphcode/vmap graphcode/hmap include
ar r $@ graphcode/*.hmap graphcode/*.vmap $^
-cd graphcode; $(GRAPHCODE_MAKE) libgraphcode.a
-cp -f graphcode/*.h include
ar r $@ $^
ifeq ($(OS),Darwin)
ranlib $@
endif
$(CPLUSPLUS) -shared -Wl,-soname,libecolab$(ECOLIBS_EXT).so.$(SOVERSION) $^ graphcode/*.hmap graphcode/*.vmap -o lib/libecolab$(ECOLIBS_EXT).so.$(SOVERSION)
$(CPLUSPLUS) -shared -Wl,-soname,libecolab$(ECOLIBS_EXT).so.$(SOVERSION) $^ -o lib/libecolab$(ECOLIBS_EXT).so.$(SOVERSION)
cd lib; ln -sf libecolab$(ECOLIBS_EXT).so.$(SOVERSION) libecolab$(ECOLIBS_EXT).so
cd lib; ln -sf libecolab$(ECOLIBS_EXT).so.$(SOVERSION) ecolab$(ECOLIBS_EXT).so

Expand Down Expand Up @@ -233,10 +225,10 @@ clean:
-$(BASIC_CLEAN) generate_nauty_sizes
-cd src; $(BASIC_CLEAN)
-cd utils; $(BASIC_CLEAN)
# -cd include; $(BASIC_CLEAN) nauty_sizes.h unpack_base.h hashmap.h vmap hmap
-cd include; $(BASIC_CLEAN) unpack_base.h hashmap.h vmap hmap
-cd include; $(BASIC_CLEAN) unpack_base.h
-cd include/Xecolab; $(BASIC_CLEAN)
-rm -f $(patsubst classdesc/%,include/%,$(wildcard classdesc/*.h))
-rm -f $(patsubst graphcode/%,include/%,$(wildcard graphcode/*.h))
-cd classdesc; $(MAKE) clean
-cd models; $(MAKE) ECOLAB_HOME=.. clean
-cd models/Stupid_Project; $(MAKE) ECOLAB_HOME=../.. clean
Expand Down
2 changes: 1 addition & 1 deletion graphcode
2 changes: 1 addition & 1 deletion include/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ endif
# do it this way to help Makefile dependencies work
ECOLIBS=$(ECOLAB_HOME)/lib/libecolab$(ECOLIBS_EXT).a

LIBS+=-L$(ECOLAB_HOME)/lib -lecolab$(ECOLIBS_EXT)
LIBS+=-L$(ECOLAB_HOME)/lib -lecolab$(ECOLIBS_EXT) -lboost_thread
FLAGS+=-I. -I$(ECOLAB_HOME)/include -DHASH_TCL_hash

# The following section uses GNU Make specific syntax. If not using
Expand Down
19 changes: 13 additions & 6 deletions include/arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ namespace ecolab
template <class E1, class E2> struct is_expression_and_scalar
{static const bool value=is_expression<E1>::value && is_scalar<E2>::value;};

/// true if both E1 and E2 are expressions, or one is and the other a scalar
template <class E1, class E2> struct is_expression_or_scalar:
public classdesc::Or<
both_are_expressions<E1,E2>,
is_expression_and_scalar<E1,E2>,
is_expression_and_scalar<E2,E1>
> {};

template <bool, class type=void> struct enable_if_c {typedef type T;};
template <class T> struct enable_if_c<false,T> {};
Expand Down Expand Up @@ -534,21 +541,21 @@ namespace ecolab
operator!(const E& e) {return unop<E,Not<typename E::value_type> >(e);}

template <class E1, class E2>
typename enable_if< one_is_expression<E1,E2>, binop<E1,E2,Add<E1,E2> > >::T
typename enable_if<is_expression_or_scalar<E1,E2>, binop<E1,E2,Add<E1,E2> > >::T
operator+(const E1& e1, const E2& e2)
{
return binop<E1,E2,Add<E1,E2> >(e1,e2);
}

template <class E1, class E2>
typename enable_if< one_is_expression<E1,E2>, binop<E1,E2,Sub<E1,E2> > >::T
typename enable_if<is_expression_or_scalar<E1,E2>, binop<E1,E2,Sub<E1,E2> > >::T
operator-(const E1& e1, const E2& e2)
{
return binop<E1,E2,Sub<E1,E2> >(e1,e2);
}

template <class E1, class E2>
typename enable_if< one_is_expression<E1,E2>, binop<E1,E2,Mul<E1,E2> > >::T
typename enable_if<is_expression_or_scalar<E1,E2>, binop<E1,E2,Mul<E1,E2> > >::T
operator*(const E1& e1, const E2& e2)
{
return binop<E1,E2,Mul<E1,E2> >(e1,e2);
Expand Down Expand Up @@ -589,7 +596,7 @@ namespace ecolab
#else

template <class E1, class E2>
typename enable_if<one_is_expression<E1,E2>, binop<E1,E2,Div<E1,E2> > >::T
typename enable_if<is_expression_or_scalar<E1,E2>, binop<E1,E2,Div<E1,E2> > >::T
operator/(const E1& e1, const E2& e2)
{
return binop<E1,E2,Div<E1,E2> >(e1,e2);
Expand All @@ -598,7 +605,7 @@ namespace ecolab
#endif

template <class E1, class E2>
typename enable_if< one_is_expression<E1,E2>, binop<E1,E2,Mod<E1,E2> > >::T
typename enable_if<is_expression_or_scalar<E1,E2>, binop<E1,E2,Mod<E1,E2> > >::T
operator%(const E1& e1, const E2& e2)
{
return binop<E1,E2,Mod<E1,E2> >(e1,e2);
Expand Down
85 changes: 27 additions & 58 deletions include/netcomplexity.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,51 +49,39 @@ using std::max;
/*
bits needed from nauty.h, macros replaced with inline C++ functions
*/
#include "nauty_sizes.h"


namespace ecolab
{
#if SIZEOF_LONG>4
#define WORDSIZE 64
#else
#define WORDSIZE 32
// use WORDSIZE to select 32 or 64 bit sets, 16 bit sets are not to be supported.
#ifdef WORDSIZE
#define ECOLAB_WORDSIZE WORDSIZE
#else // 64 bit sets are default.
#define ECOLAB_WORDSIZE 64
#endif

#if WORDSIZE==32
#if SIZEOF_INT>=4
typedef unsigned int setword;
#define SETWORD_INT
#else
typedef unsigned long setword;
#define SETWORD_LONG
#endif
#endif

#if WORDSIZE==64
#if SIZEOF_INT>=8
typedef unsigned int setword;
#define SETWORD_INT
#else
#if SIZEOF_LONG>=8
#if ECOLAB_WORDSIZE==64
#if UINT_MAX>0xFFFFFFFF
typedef unsigned setword;
#elif ULONG_MAX> 0xFFFFFFFF
typedef unsigned long setword;
#define SETWORD_LONG
#else
typedef unsigned long long setword;
#define SETWORD_LONGLONG
#endif
#endif
#elif ECOLAB_WORDSIZE==32
typedef unsigned int setword;
#else
#error "No integer format matches WORDSIZE"
#endif

#if (WORDSIZE==64)
const setword MSK64=0xFFFFFFFFFFFFFFFFUL;
const setword MSK63C=0x7FFFFFFFFFFFFFFFUL;

#if ECOLAB_WORDSIZE==64
const setword MSK64=0xFFFFFFFFFFFFFFFFULL;
const setword MSK63C=0x7FFFFFFFFFFFFFFFULL;
const setword ALLBITS=MSK64;
inline unsigned SETWD(unsigned pos) {return pos>>6;}
inline unsigned SETBT(unsigned pos) {return pos&0x3F;}
inline setword BITMASK(unsigned x) {return MSK63C >> x;}

#ifdef SETWORD_LONGLONG
const setword bitt[] = {01000000000000000000000LL,0400000000000000000000LL,
0200000000000000000000LL,0100000000000000000000LL,
040000000000000000000LL,020000000000000000000LL,
Expand All @@ -114,26 +102,7 @@ namespace ecolab
0200000LL,0100000LL,040000LL,020000LL,010000LL,04000LL,
02000LL,01000LL,0400LL,0200LL,0100LL,040LL,020LL,010LL,
04LL,02LL,01LL};
#else
const setword bitt[] = {01000000000000000000000,0400000000000000000000,
0200000000000000000000,0100000000000000000000,
040000000000000000000,020000000000000000000,
010000000000000000000,04000000000000000000,
02000000000000000000,01000000000000000000,
0400000000000000000,0200000000000000000,
0100000000000000000,040000000000000000,020000000000000000,
010000000000000000,04000000000000000,02000000000000000,
01000000000000000,0400000000000000,0200000000000000,
0100000000000000,040000000000000,020000000000000,
010000000000000,04000000000000,02000000000000,
01000000000000,0400000000000,0200000000000,0100000000000,
040000000000,020000000000,010000000000,04000000000,
02000000000,01000000000,0400000000,0200000000,0100000000,
040000000,020000000,010000000,04000000,02000000,01000000,
0400000,0200000,0100000,040000,020000,010000,04000,
02000,01000,0400,0200,0100,040,020,010,04,02,01};
#endif
#else
#elif ECOLAB_WORDSIZE==32
const setword MSK32=0xFFFFFFFFUL;
const setword MSK31C=0x7FFFFFFFUL;
const setword ALLBITS=MSK32;
Expand Down Expand Up @@ -223,7 +192,7 @@ namespace ecolab
std::vector<setword> data;

unsigned nwords() const {return sz? div(sz-1)+1: 0;}
unsigned nbytes() const {return nwords()*(WORDSIZE>>3);}
unsigned nbytes() const {return nwords()*sizeof(setword);}
unsigned div(unsigned i) const {return SETWD(i);} /* i/WORDSIZE; */
unsigned mod(unsigned i) const {return SETBT(i);} /* i%WORDSIZE; */
unsigned mod(int i) const {return SETBT(i);} /* i%WORDSIZE; */
Expand Down Expand Up @@ -286,10 +255,10 @@ namespace ecolab
bitvect operator>>(unsigned offs) const {
bitvect r(sz+offs);
for (unsigned i=0; i<nwords()-1; ++i) {
r.data[div(i*WORDSIZE+offs)+1] = data[i]>>mod(offs);
r.data[div(i*WORDSIZE+offs)] = data[i]<<mod(-offs);
r.data[div(i*ECOLAB_WORDSIZE+offs)+1] = data[i]>>mod(offs);
r.data[div(i*ECOLAB_WORDSIZE+offs)] = data[i]<<mod(-offs);
}
r.data[div((nwords()-1)*WORDSIZE+offs)] = data[nwords()-1]<<mod(-offs);
r.data[div((nwords()-1)*ECOLAB_WORDSIZE+offs)] = data[nwords()-1]<<mod(-offs);
return r;
}
bitvect num(unsigned start,unsigned nbits) const;
Expand Down Expand Up @@ -492,7 +461,7 @@ namespace ecolab
const_iterator end() const {return const_iterator(*this,true);}

unsigned m() const {return SETWD(nodecnt-1)+1;}
unsigned mw() const {return WORDSIZE*m();}
unsigned mw() const {return ECOLAB_WORDSIZE*m();}
bitvect linklist;

NautyRep(): nodecnt(0) {}
Expand Down Expand Up @@ -700,7 +669,7 @@ namespace ecolab
inline bitvect bitvect::num(unsigned start,unsigned nbits) const
{
bitvect r(nbits);
if (start+nbits<WORDSIZE)
if (start+nbits<ECOLAB_WORDSIZE)
r.data[0]= (data[0]<<start) & ~bitrange(nbits);
else
for (unsigned i=0; i<nbits; i++)
Expand All @@ -720,14 +689,14 @@ namespace ecolab
inline bool bitvect::equal(const bitvect& y, unsigned len, unsigned offs) const
{
bool r=true;
if (offs+len>WORDSIZE)
if (offs+len>ECOLAB_WORDSIZE)
{
unsigned i;
for (i=0; r && i<div(len); i++)
r&= data[i]==(y.data[div(offs)+i]<<mod(offs)|
y.data[div(offs)+i+1]>>(WORDSIZE-mod(offs)));
y.data[div(offs)+i+1]>>(ECOLAB_WORDSIZE-mod(offs)));
unsigned lastword= (div(offs)+i+1<y.nwords())?
y.data[div(offs)+i+1]>>(WORDSIZE-mod(offs)): 0;
y.data[div(offs)+i+1]>>(ECOLAB_WORDSIZE-mod(offs)): 0;
r&= !(~bitrange(mod(len)) &
(data[i] ^ (y.data[div(offs)+i]<<mod(offs)| lastword)));
}
Expand Down
2 changes: 1 addition & 1 deletion include/sparse_mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ecolab
/*matrix multiplication*/
template <class E> typename
array_ns::enable_if< array_ns::is_expression<E>, array_ns::array<double> >::T
operator*(const E& x)
operator*(const E& x) const
{
array_ns::array<double> r;
assert(row.size()==col.size() && row.size()==val.size());
Expand Down
Loading

0 comments on commit 1f05534

Please sign in to comment.