Load balance database checked in
authorRobert Brunner <rbrunner@uiuc.edu>
Mon, 9 Aug 1999 22:33:08 +0000 (22:33 +0000)
committerRobert Brunner <rbrunner@uiuc.edu>
Mon, 9 Aug 1999 22:33:08 +0000 (22:33 +0000)
62 files changed:
src/arch/exemplar/conv-mach.h
src/arch/mpi-exemplar/conv-mach.h
src/arch/mpi-linux/conv-mach.h
src/arch/mpi-origin/conv-mach.h
src/arch/ncube2/conv-mach.h
src/arch/net-aix-ppc/conv-mach.h
src/arch/net-axp/conv-mach.h
src/arch/net-hp-acc/conv-mach.h
src/arch/net-hp-cc/conv-mach.h
src/arch/net-hp/conv-mach.h
src/arch/net-irix-64/conv-mach.csh
src/arch/net-irix-64/conv-mach.h
src/arch/net-irix/conv-mach.h
src/arch/net-linux-kcc/conv-mach.h
src/arch/net-linux-smp/conv-mach.h
src/arch/net-linux/conv-mach.h
src/arch/net-sol-cc/conv-mach.csh
src/arch/net-sol-cc/conv-mach.h
src/arch/net-sol-smp/conv-mach.h
src/arch/net-sol/conv-mach.h
src/arch/net-sun/conv-mach.h
src/arch/origin-pthreads/conv-mach.h
src/arch/origin2000/conv-mach.h
src/arch/paragon-red/conv-mach.h
src/arch/sim-hp/conv-mach.h
src/arch/sim-irix-64/conv-mach.h
src/arch/sim-irix/conv-mach.h
src/arch/sim-linux/conv-mach.h
src/arch/sim-rs6k/conv-mach.h
src/arch/sim-sol/conv-mach.h
src/arch/sim-sun/conv-mach.h
src/arch/sp3/conv-mach.h
src/arch/t3e/conv-mach.h
src/arch/uth-axp-cc/conv-mach.h
src/arch/uth-hp-cc/conv-mach.h
src/arch/uth-hp/conv-mach.h
src/arch/uth-irix-64/conv-mach.h
src/arch/uth-irix/conv-mach.h
src/arch/uth-linux/conv-mach.h
src/arch/uth-rs6k/conv-mach.h
src/arch/uth-sol-cc/conv-mach.h
src/arch/uth-sol/conv-mach.h
src/ck-core/charm++.h
src/ck-core/ckarray.C
src/ck-core/ckarray.h
src/ck-ldb/CentralLB.C [new file with mode: 0644]
src/ck-ldb/CentralLB.ci [new file with mode: 0644]
src/ck-ldb/CentralLB.h [new file with mode: 0644]
src/ck-ldb/LBDB.C [new file with mode: 0644]
src/ck-ldb/LBDB.h [new file with mode: 0644]
src/ck-ldb/LBDatabase.C [new file with mode: 0644]
src/ck-ldb/LBDatabase.ci [new file with mode: 0644]
src/ck-ldb/LBDatabase.h [new file with mode: 0644]
src/ck-ldb/LBOM.h [new file with mode: 0644]
src/ck-ldb/LBObj.C [new file with mode: 0644]
src/ck-ldb/LBObj.h [new file with mode: 0644]
src/ck-ldb/RandCentLB.C [new file with mode: 0644]
src/ck-ldb/RandCentLB.ci [new file with mode: 0644]
src/ck-ldb/RandCentLB.h [new file with mode: 0644]
src/ck-ldb/lbdb.C [new file with mode: 0644]
src/ck-ldb/lbdb.h [new file with mode: 0644]
src/scripts/Makefile

index a6c34a312f5b07f8d36feb7e6d84e0347466c266..45df0eab8684353c482efda9b6ac32d121c4aa8c 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #define CPP_LOCATION "/lib/cpp"
 
 #endif
index a202ab3dca825ca18051af5590e629f0727d3ebe..bac7c9d2a0aa400f6ddbe11e17d7a79441beb0a6 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #define CPP_LOCATION "/lib/cpp"
 
 #endif
index 07b750136416ccf49eaaafedfbff37c7349c54a4..aeaccdcc7845b42087e21a5b5d0b0b6f287d9bd2 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 4dc6f88bb0927b9ae5deda11deb20c92bda9f9cd..c9c959223ca5da1c3b7a8c869098d3c95dab5b56 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index c846b5ec33cbeb94e86299d82bd5ce007d55c79d..855189c2ea0f8028137883119481217d5680d36d 100644 (file)
 
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index f4fb534e5f50dfae2ead6a80373ae87949d24130..08773b77b28ba11c699c45bf3facdb8496460a74 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 1883fad62ae6c3079f306b1855bad484190ecfca..ad8c4ca58dd547c3bc07ce1a37f64340a6594db4 100644 (file)
 
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 50eeda6a322e4d0d1e4f726d53000c218ee6fd78..63cb7f3348187e3e46e62c5b59819f2be0f2222f 100644 (file)
 
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 1cd1ee4bd0242f03ddd1f321e93c925d9e5d883a..9c245988bd57b4b3f77e61f7cbfd443f4b74ed30 100644 (file)
 
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index f1bb1b1c63826867741fc18928858ab3c3440cb5..704299709b50bf68baa7409fd9cdacd3d0bb8741 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 5cdf0ee3dbdbb8f5f0112b7efbccf7c5ef968853..4b200cd628d95cf19e593557f5851879c33e59cc 100755 (executable)
@@ -1,7 +1,5 @@
 set CMK_CPP_CHARM='/usr/lib/cpp '
-set CMK_CPP_C='cc -E -64 '
-set CMK_LDRO='ld -r -o'
-set CMK_LDRO_WORKS=0
+set CMK_CPP_C='cc -64 -E '
 set CMK_CC='cc  -w -64 '
 set CMK_CC_RELIABLE='cc  -w -64 '
 set CMK_CC_FASTEST='cc  -w -64 '
@@ -26,10 +24,8 @@ set CMK_SEQ_CC='cc -w -64 '
 set CMK_SEQ_LD='cc -w -64 '
 set CMK_SEQ_CXX='CC -w -64 '
 set CMK_SEQ_LDXX='CC -w -64 '
-set CMK_NM='nm'
-set CMK_NM_FILTER="grep '|GLOB |' | sed -e 's/.*|//'"
 set CMK_CPP_SUFFIX="i"
-set CMK_XLATPP='charmxlat++ -w '
+set CMK_XLATPP='charmxlat++  '
 set CMK_QT='origin'
 set CMK_XIOPTS=''
 
index f567d219a632d97e4427089ed7a526afb040a75c..4cced6bb3b646483e2c3e0f20252a49b6e0d7deb 100644 (file)
 
 #define CMK_FIX_HP_CONNECT_BUG                             0
 
-#define CMK_GETPAGESIZE_AVAILABLE                          0
+#define CMK_GETPAGESIZE_AVAILABLE                          1
 
 #define CMK_IS_HETERO                                      1
 
-#define CMK_MACHINE_NAME                                   "net-irix-64"
+#define CMK_MACHINE_NAME                                   "net-irix"
 
-#define CMK_MALLOC_USE_GNU_MALLOC                          0
-#define CMK_MALLOC_USE_OS_BUILTIN                          1
+#define CMK_MALLOC_USE_GNU_MALLOC                          1
+#define CMK_MALLOC_USE_OS_BUILTIN                          0
 
 #define CMK_MEMORY_PAGESIZE                                8192
 #define CMK_MEMORY_PROTECTABLE                             0
@@ -68,7 +68,7 @@
 #define CMK_SIGNAL_USE_SIGACTION                           0
 #define CMK_SIGNAL_USE_SIGACTION_WITH_RESTART              1
 
-#define CMK_SIZE_T                                         unsigned long
+#define CMK_SIZE_T                                         unsigned int
 
 #define CMK_SPANTREE_MAXSPAN                               4
 #define CMK_SPANTREE_USE_COMMON_CODE                       1
 
 #define CMK_SYNCHRONIZE_ON_TCP_CLOSE                       0
 
-#define CMK_THREADS_REQUIRE_NO_CPV                         0
-#define CMK_THREADS_COPY_STACK                             0
-
 #define CMK_THREADS_UNAVAILABLE                            0
 #define CMK_THREADS_USE_ALLOCA                             0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
 #define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 #define CMK_THREADS_USE_JB_TWEAKING_ORIGIN                 1
 
+#define CMK_THREADS_REQUIRE_NO_CPV                         0
+#define CMK_THREADS_COPY_STACK                             0
+
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
 #define CMK_TIMER_USE_TIMES                                1
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_DEBUG_MODE                                     0
+#define CMK_WEB_MODE                                       0
+#define CMK_USE_PERSISTENT_CCS                             0
+
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 13278b20171225266d95a84f648078b631ee772f..4cced6bb3b646483e2c3e0f20252a49b6e0d7deb 100644 (file)
 #define CMK_WEB_MODE                                       0
 #define CMK_USE_PERSISTENT_CCS                             0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index ab4268327b00277cc17e4c9466c5af0e6533da85..d21dba8ab27ce37ed6fe404ea78f65dcfda39e45 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               0
 #define CMK_COMPILEMODE_ANSI                               1
 
+#define CMK_LBDB_ON                                       1
+#define CMK_LBDB_OFF                                      0
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  1
+#define CMK_BOOL_UNDEFINED                                0
+
 #endif
 
index cdf0bb6ece41dd7af09cbcae3f0ce07f6f150cfb..7e5edf5ab6d61d89a01e2c5ba6ce80df6f2c7b20 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index c717825491f4e55efc06e426d7940668c974a9e7..e66ef52c8d0538f145c2cb2bf90e8100b936d231 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
 
+
index 7e790896a5917fef727868b4d20e5ed283cebf77..1f10f25f64690e75e4a8e2f8c847299483c58e8b 100755 (executable)
@@ -3,7 +3,7 @@ set CMK_CPP_C='cc -E '
 set CMK_CC='cc -Kpic '
 set CMK_CC_RELIABLE='cc '
 set CMK_CC_FASTEST='cc '
-set CMK_CXX='CC -Kpic '
+set CMK_CXX='CC -Kpic -library=Cstd'
 set CMK_CXXPP='CC -E '
 set CMK_CF77='f77'
 set CMK_CF90='f90'
@@ -12,7 +12,7 @@ set CMK_C_OPTIMIZE='-fast'
 set CMK_CXX_DEBUG='-g'
 set CMK_CXX_OPTIMIZE='-fast'
 set CMK_LD='cc '
-set CMK_LDXX='CC '
+set CMK_LDXX='CC -library=Cstd'
 set CMK_LD77=''
 set CMK_M4='m4'
 set CMK_SUF='o'
@@ -22,8 +22,8 @@ set CMK_LIBS='-lnsl -lsocket -lckqt'
 set CMK_SEQ_LIBS='-lnsl -lsocket'
 set CMK_SEQ_CC='cc'
 set CMK_SEQ_LD='cc'
-set CMK_SEQ_CXX='CC'
-set CMK_SEQ_LDXX='CC'
+set CMK_SEQ_CXX='CC -library=Cstd'
+set CMK_SEQ_LDXX='CC -library=Cstd'
 set CMK_CPP_SUFFIX="cc"
 set CMK_XLATPP='charmxlat++ -w -p '
 set CMK_QT='solaris-cc'
index 2e9dbd0bb0ed33d816efbbf6e9187029c124bc62..ce880d044aa67833635c93584745660b65b1b112 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       1
+#define CMK_LBDB_OFF                                      0
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/ccs/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  1
+#define CMK_BOOL_UNDEFINED                                0
+
 #endif
 
index dd92474872e3ae3fc31dbf626829673962933659..6aa3fed1383a62d168f5b5f3739a6a200b355716 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/ccs/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 994ffecf8e7d980b9ce4501e05d5124168424bc6..33efcd1cdf6f13fb0cd53eccc46026b169af6391 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/ccs/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  1
+#define CMK_BOOL_UNDEFINED                                0
+
 #endif
 
index db250ae796edd153363002e80b7a649c048f18c9..192fc9de491744869c0b93e6e43b56935511f1dd 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 955de5bf1a233c837ef8999f244f19f95dc00c03..3204099ebbb6aa71fbd6c5c27187705d93ec94b6 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index ac8c8b20202e1080e3cf49b5ab1662ee7b05bd94..8961be739391ef9a87ac38055038eac3ae874c5f 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       1
+#define CMK_LBDB_OFF                                      0
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  1
+#define CMK_BOOL_UNDEFINED                                0
+
 #endif
 
index b7a5346f47c8b7167d340be7c1b68cdb850c0f03..b3dc1492e3eba648cafbfba8933ddddb7b9040b8 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index ac7de699b779bec0d0f15717d053050d826b5640..d79104cd79983de341955e3cff2a071290ded69f 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 89df13ee1c737a6e851e29dcd52ff8b7b64fcdf2..b59cf2d1ad948108b6af7bcda883577bf9eccbb0 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index a763216e2c259b8cad0d41f4df0fc0e8b20f9fe6..ea73dee5e6c1301695ddbc8dd678b5c37a077753 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index dee96eb3242a72075daa2514a16178db6b6952c0..7807fb51b7de10ee992974f91b0902889a9419f7 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index c3511f3af5e703c2326516072ef0dd3a9e329c43..0b3a4b21721d3749525a0f8b7598bded34481f57 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 16fe1e17cb8da244038a20183c652af4e9eea67f..874f95c8f534ad609ade8efd86662ca318d924cf 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/ccs/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index a542017fb2fdf31cb25976dafe51bea61790ef55..a40ac0a91f351e33950ee50370961bb364bceadd 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index f55a5661a3a812f8bff06bdf26d1f9eb33f007a6..ac7d344d70ece2fa07d5fbe7805f659bdaac515b 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index b3590a5cbb99c46f4eb59c9f436089ece16a1abb..e0e7110a0ce99ceef6637686b63bdb3897d0770a 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "cpp"
 
+#define CMK_BOOL_DEFINED                                  1
+#define CMK_BOOL_UNDEFINED                                0
+
 #endif
 
index 8fe5b740f38a174a101b447cc1ce68baa5c41188..9367bd89dae8c824566c6645de09df92bceb3c59 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index f1b2871b4a8db8a02618250dafedaf9bdeaa916b..b5b38b5dbfa54766151aa633ff81e36bd5d8c92b 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 71508c981fa96acc99294a851cd98347d982af60..bfe0700ea7c4c7df76e397c754a2afeba1b211ef 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 7b2e1c5b48c09a5a364571107405a2b76e77720c..b4a076cb8910e84de1e931cd87885bf9e467313b 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 081f6a719d0c9af97b85c9c2b94c7eb75934ced7..3ae22ab8c07ec63c27fcc91225da7b6c0f539974 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index e865eafbfdab0e8a37a39867683124b000be8334..8dcbb7bebe3e70185404255d7685a4ddb1841894 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index bf472f0f735ef31b009b2b5074b4ba45b93d78e1..155e5b509c6e63041b336951cc6861465819a879 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 12ec49b19a14aa57f73e04382224e6c7423f952e..412da84a893f232e1fcbcb7b2b5c0814956cbbd9 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/ccs/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 8e0a049f5de8a33b74fbf7b00f353fd310d575c6..46d8a3e4739d4865c93e3f3525c645bb9979c91e 100644 (file)
 #define CMK_COMPILEMODE_ORIG                               1
 #define CMK_COMPILEMODE_ANSI                               0
 
+#define CMK_LBDB_ON                                       0
+#define CMK_LBDB_OFF                                      1
+
+#define CMK_STL_USE_DOT_H                                  0
+#define CMK_STL_DONT_USE_DOT_H                             1
+
 #define CPP_LOCATION "/usr/ccs/lib/cpp"
 
+#define CMK_BOOL_DEFINED                                  0
+#define CMK_BOOL_UNDEFINED                                1
+
 #endif
 
index 6a65ada510b756e4dee25d329835eb7c3af1cea1..9486b49ecc54e2e910fc88a3df2ab13eef8629ee 100644 (file)
@@ -7,6 +7,10 @@
 #include <string.h>
 #endif
 
+#if CMK_BOOL_UNDEFINED
+enum bool {false=0, true=1};
+#endif
+
 #if CMK_DEBUG_MODE
 class Chare;
 extern void putObject(Chare *);
index 8d666cfdf469cc5b0453e4a1334345e00b06bceb..053276290bb6cd0db5c5552eb5eaf8b4e3341402 100644 (file)
@@ -1,8 +1,14 @@
 #include "charm++.h"
+#include "register.h"
+#include "ckarray.h"
 #include "ck.h"
 #include "CkArray.def.h"
 #include "init.h"
 
+#if CMK_LBDB_ON
+#include "LBDatabase.h"
+#endif // CMK_LBDB_ON
+
 CkGroupID _RRMapID;
 
 void *
@@ -55,6 +61,10 @@ CkGroupID Array1D::CreateArray(int numElements,
   msg->elementChareType = elementChare;
   msg->elementConstType = elementConstructor;
   msg->elementMigrateType = elementMigrator;
+#if CMK_LBDB_ON
+  CmiPrintf("Creating array %d\n",lbdb);
+  msg->loadbalancer = lbdb;
+#endif
   group = CProxy_Array1D::ckNew(msg);
 
   return group;
@@ -67,6 +77,26 @@ Array1D::Array1D(ArrayCreateMessage *msg)
   elementConstType = msg->elementConstType;
   elementMigrateType = msg->elementMigrateType;
 
+#if CMK_LBDB_ON
+  the_lbdb = CProxy_LBDatabase(msg->loadbalancer).ckLocalBranch();
+
+  //  int iii=0;
+  //  CkPrintf("%d Hi from Array1D[%d]\n",iii++,CkMyPe());
+
+  // Register myself as an array manager
+  LDOMid myId;
+  myId.id = (int)thisgroup;
+
+  LDCallbacks myCallbacks;
+  myCallbacks.migrate = staticMigrate;
+  myCallbacks.setStats = staticSetStats;
+  myCallbacks.queryEstLoad = staticQueryLoad;
+  
+  myHandle = the_lbdb->RegisterOM(myId,this,myCallbacks);
+  CkPrintf("[%d] Created myHandle %d\n",CkMyPe(),myHandle.handle);
+
+#endif
+
   ArrayMapRegisterMessage *mapMsg = new ArrayMapRegisterMessage;
   mapMsg->numElements = numElements;
   mapMsg->arrayID = thishandle;
@@ -86,10 +116,6 @@ Array1D::Array1D(ArrayCreateMessage *msg)
   }
 
   delete msg;
-
-  /*
-  CkPrintf("Array1D constructed\n");
-  */
 }
 
 void Array1D::RecvMapID(ArrayMap *mPtr, int mHandle)
@@ -102,6 +128,14 @@ void Array1D::RecvMapID(ArrayMap *mPtr, int mHandle)
   elementIDsReported = 0;
   numLocalElements=0;
   int i;
+
+#if CMK_LBDB_ON
+  // Tell the lbdb that I'm registering objects, until I'm done
+  // registering them.
+  CkPrintf("[%d] using myHandle %d\n",CkMyPe(),myHandle.handle);
+  the_lbdb->RegisteringObjects(myHandle);
+#endif
+
   for(i=0; i < numElements; i++)
   {
     elementIDs[i].originalPE = elementIDs[i].pe = map->procNum(mapHandle, i);
@@ -126,6 +160,10 @@ void Array1D::RecvMapID(ArrayMap *mPtr, int mHandle)
       CkCreateChare(elementChareType, elementConstType, msg, 0, CkMyPe());
     }
   }
+#if CMK_LBDB_ON
+  if (numLocalElements==0)
+    the_lbdb->DoneRegisteringObjects(myHandle);
+#endif
   CProxy_Array1D arr(thisgroup);
   ArrayMessage *amsg;
   while((amsg = (ArrayMessage *) bufferedForElement->deq())) {
@@ -139,17 +177,36 @@ void Array1D::RecvMapID(ArrayMap *mPtr, int mHandle)
   delete bufferedMigrated;
 }
 
-void Array1D::RecvElementID(int index, ArrayElement *elem, CkChareID handle)
+void Array1D::RecvElementID(int index, ArrayElement *elem,
+                           CkChareID handle, bool use_local_barrier)
 {
   elementIDs[index].state = here;
   elementIDs[index].element = elem;
   elementIDs[index].elementHandle = handle;
   elementIDsReported++;
 
-  /*
+  //  if (elementIDsReported == numLocalElements)
+  //    CkPrintf("PE %d all elements reported in\n",CkMyPe());
+
+#if CMK_LBDB_ON
+  // Register the object with the load balancer
+  LDObjid elemID;
+  elemID.id[0] = index;
+  elemID.id[1] = elemID.id[2] = elemID.id[3] = 0;
+
+  //  CkPrintf("Registering object\n");
+  elementIDs[index].ldHandle = the_lbdb->RegisterObj(myHandle,elemID,0,1);
+
+  if (use_local_barrier)
+    RegisterElementForSync(index);
+  else
+    elementIDs[index].uses_barrier = false;
+
   if (elementIDsReported == numLocalElements)
-    CkPrintf("PE %d all elements reported in\n",CkMyPe());
-  */
+    the_lbdb->DoneRegisteringObjects(myHandle);
+    
+#endif
+
 }
 
 static int serial_num = 0;
@@ -197,6 +254,7 @@ void Array1D::send(ArrayMessage *msg, int index, EntryIndexType ei)
 void Array1D::broadcast(ArrayMessage *msg, EntryIndexType ei)
 {
   CkPrintf("Broadcast not implemented\n");
+  delete msg;
 }
 
 void Array1D::RecvForElement(ArrayMessage *msg)
@@ -212,19 +270,19 @@ void Array1D::RecvForElement(ArrayMessage *msg)
   if (elementIDs[msg->destIndex].state == here) {
     // CkPrintf("PE %d DELIVERING index %d RecvForElement state %d\n",
     // CkMyPe(),msg->destIndex,elementIDs[msg->destIndex].state);
-    // CkSendMsg(msg->entryIndex,msg,&elementIDs[msg->destIndex].elementHandle);
-    //    register int epIdx = env->getEpIdx();
+
     register int epIdx = msg->entryIndex;
-    //    register void *obj = env->getObjPtr();
     CkChareID handle = elementIDs[msg->destIndex].elementHandle;
     register void *obj = handle.objPtr;
+
+#if CMK_LBDB_ON
+    the_lbdb->ObjectStart(elementIDs[msg->destIndex].ldHandle);
+    _entryTable[epIdx]->call(msg, obj);
+    the_lbdb->ObjectStop(elementIDs[msg->destIndex].ldHandle);
+#else
     _entryTable[epIdx]->call(msg, obj);
+#endif
 
-    //    EP_STRUCT *epinfo = CsvAccess(EpInfoTable)+msg->entryIndex;
-    //    CHARE_BLOCK *chareblock = GetID_chareBlockPtr(handle);
-    //    void *current_usr = msg;
-    //USER_MSG_PTR(env);
-    //    callep(epinfo->function,msg,chareblock->chareptr);
  } else if (elementIDs[msg->destIndex].state == at) {
     // CkPrintf("PE %d Sending to SELF index %d RecvForElement state %d\n",
       // CkMyPe(),msg->destIndex,elementIDs[msg->destIndex].state);
@@ -248,10 +306,24 @@ void Array1D::migrateMe(int index, int where)
   msg->from = CkMyPe();
   msg->elementSize = bufSize;
   msg->hopCount = elementIDs[index].curHop + 1;
+#if CMK_LBDB_ON
+  msg->uses_barrier = elementIDs[index].uses_barrier;
+#endif
+
   elementIDs[index].element->pack(msg->elementData);
   elementIDs[index].state = moving_to;
   elementIDs[index].pe = where;
+
+#if CMK_LBDB_ON
+  the_lbdb->UnregisterObj(elementIDs[index].ldHandle);
+  if (elementIDs[index].uses_barrier)
+    the_lbdb->RemoveLocalBarrierClient(elementIDs[index].barrierHandle);
+#endif
+  CkPrintf("[%d] Element %d migrating away\n",CkMyPe(),index);
+
   numLocalElements--;
+  elementIDsReported--;
+
   CProxy_Array1D arr(thisgroup);
   arr.RecvMigratedElement(msg, where);
 }
@@ -270,6 +342,10 @@ void Array1D::RecvMigratedElement(ArrayMigrateMessage *msg)
   elementIDs[index].cameFrom = msg->from;
   elementIDs[index].migrateMsg = msg;
 
+#if CMK_LBDB_ON
+  elementIDs[index].uses_barrier = msg->uses_barrier;
+#endif
+   
   ArrayElementMigrateMessage *new_msg = new ArrayElementMigrateMessage;
 
   new_msg->index = index;
@@ -280,6 +356,8 @@ void Array1D::RecvMigratedElement(ArrayMigrateMessage *msg)
   new_msg->packData = msg->elementData;
   
   CkCreateChare(elementChareType, elementMigrateType, new_msg, 0, CkMyPe());
+
+
 }
 
 void Array1D::RecvMigratedElementID(int index, ArrayElement *elem,
@@ -316,6 +394,23 @@ void Array1D::RecvMigratedElementID(int index, ArrayElement *elem,
     arr.AckMigratedElement(ack_msg, elementIDs[index].originalPE);
   }
   numLocalElements++;
+  elementIDsReported++;
+
+#if CMK_LBDB_ON
+  // Register the object with the load balancer
+  LDObjid elemID;
+  elemID.id[0] = index;
+  elemID.id[1] = elemID.id[2] = elemID.id[3] = 0;
+
+  CkPrintf("[%d] Registering Migrated object index %d\n",CkMyPe(),index);
+  elementIDs[index].ldHandle = the_lbdb->RegisterObj(myHandle,elemID,0,1);
+
+  if (elementIDs[index].uses_barrier)
+    RegisterElementForSync(index);
+
+  the_lbdb->Migrated(elementIDs[index].ldHandle);
+#endif
+
 }
 
 void Array1D::AckMigratedElement(ArrayElementAckMessage *msg)
@@ -343,6 +438,101 @@ void Array1D::AckMigratedElement(ArrayElementAckMessage *msg)
   delete msg;
 }
 
+#if CMK_LBDB_ON
+
+void Array1D::staticMigrate(LDObjHandle _h, int _dest)
+{
+  (static_cast<Array1D*>(_h.omhandle.user_ptr))->Migrate(_h,_dest);
+}
+
+void Array1D::staticSetStats(LDOMHandle _h, int _state)
+{
+  (static_cast<Array1D*>(_h.user_ptr))->SetStats(_h,_state);   
+}
+
+void Array1D::staticQueryLoad(LDOMHandle _h)
+{
+  (static_cast<Array1D*>(_h.user_ptr))->QueryLoad(_h);
+}
+
+void Array1D::Migrate(LDObjHandle _h, int _dest)
+{
+  int id = _h.id.id[0];
+  if (elementIDs[id].state != here)
+    CkPrintf("%s(%d)[%d]: Migrate error, element not present\n",
+            __FILE__,__LINE__,CkMyPe());
+  else
+    elementIDs[id].element->migrate(_dest);
+  
+}
+
+void Array1D::SetStats(LDOMHandle _h, int _state)
+{
+  CkPrintf("%s(%d)[%d]: SetStats request received\n",
+          __FILE__,__LINE__,CkMyPe());
+}
+
+void Array1D::QueryLoad(LDOMHandle _h)
+{
+  CkPrintf("%s(%d)[%d]: QueryLoad request received\n",
+          __FILE__,__LINE__,CkMyPe());
+}
+
+void Array1D::RegisterElementForSync(int index)
+{
+  CkPrintf("[%d] Registering element %d for barrier\n",CkMyPe(),index);
+  if (elementIDsReported == 1) { // This is the first element reported
+    // If this is a sync array, register a sync callback so I can
+    // inform the db when I start registering objects 
+    the_lbdb->AddLocalBarrierReceiver(staticRecvAtSync,
+                                     static_cast<void*>(this));
+  }
+    
+  elementIDs[index].uses_barrier = true;  
+  elementIDs[index].barrierData.me = this;
+  elementIDs[index].barrierData.index = index;
+
+  elementIDs[index].barrierHandle = the_lbdb->
+    AddLocalBarrierClient(staticResumeFromSync,
+                         static_cast<void*>(&elementIDs[index].barrierData));
+
+}
+
+void Array1D::staticRecvAtSync(void* data)
+{
+  static_cast<Array1D*>(data)->RecvAtSync();
+}
+
+void Array1D::RecvAtSync()
+{
+  // If all of our elements leave, there won't be anything to
+  // call DoneRegisteringObjects();
+  the_lbdb->RegisteringObjects(myHandle);
+}
+
+void Array1D::staticResumeFromSync(void* data)
+{
+  ElementIDs::BarrierClientData* barrierData = 
+    static_cast<ElementIDs::BarrierClientData*>(data);
+  (barrierData->me)->ResumeFromSync(barrierData->index);
+}
+
+void Array1D::ResumeFromSync(int index)
+{
+  the_lbdb->DoneRegisteringObjects(myHandle);
+
+  if (elementIDs[index].state == here)
+    elementIDs[index].element->ResumeFromSync();
+  else {
+    CkPrintf("!!! I'm supposed to resume an element, but it has left !!!\n");
+  }
+}
+
+void Array1D::AtSync(int index)
+{
+  the_lbdb->AtLocalBarrier(elementIDs[index].barrierHandle);
+}
+#endif // CMK_LBDB_ON
 
 ArrayElement::ArrayElement(ArrayElementCreateMessage *msg)
 {
@@ -368,9 +558,9 @@ ArrayElement::ArrayElement(ArrayElementMigrateMessage *msg)
   thisIndex = msg->index;
 }
 
-void ArrayElement::finishConstruction(void)
+void ArrayElement::finishConstruction(bool use_local_barrier)
 {
-  thisArray->RecvElementID(thisIndex, this, thishandle);
+  thisArray->RecvElementID(thisIndex, this, thishandle, use_local_barrier);
 }
 
 void ArrayElement::finishMigration(void)
@@ -390,6 +580,14 @@ void ArrayElement::migrate(int where)
 */
 }
 
+void ArrayElement::AtSync(void)
+{
+  CkPrintf("Element %d at sync\n",thisIndex);
+#if CMK_LBDB_ON
+  thisArray->AtSync(thisIndex);
+#endif
+}
+
 void ArrayElement::exit(ArrayElementExitMessage *msg)
 {
   delete msg;
@@ -397,6 +595,24 @@ void ArrayElement::exit(ArrayElementExitMessage *msg)
   delete this;
 }
 
+#if 0
+ArrayMap::ArrayMap(ArrayMapCreateMessage *msg)
+{
+  // CkPrintf("PE %d creating ArrayMap\n",CkMyPe());
+  arrayChareID = msg->arrayID;
+  arrayGroupID = msg->groupID;
+  array = CProxy_Array1D::ckLocalBranch(arrayGroupID);
+  numElements = msg->numElements;
+
+  delete msg;
+}
+
+void ArrayMap::finishConstruction(void)
+{
+  array->RecvMapID(this, thishandle, thisgroup);
+}
+#endif
+
 RRMap::RRMap(void)
 {
   // CkPrintf("PE %d creating RRMap for %d elements\n",CkMyPe(),numElements);
index 33b34a56120cafcfa2e52d4dd572a030253e1161..bd244a4b0307dee2e3c00782075f868209deceaf 100644 (file)
@@ -3,6 +3,12 @@
 
 #include "charm++.h"
 
+#if CMK_LBDB_ON
+#include "LBDatabase.h"
+#endif
+
+extern void _registerCkArray(void);
+
 class PtrQ;
 class PtrVec;
 
@@ -19,6 +25,10 @@ typedef int EntryIndexType;
 
 extern CkGroupID _RRMapID;
 
+#if CMK_LBDB_ON
+class LBDatabase;
+#endif
+
 class Array1D;
 class ArrayMapRegisterMessage;
 class ArrayElementCreateMessage;
@@ -37,26 +47,41 @@ class ArrayElement : public Chare
 {
 friend class Array1D;
 public:
-  ArrayElement(void) {};
   ArrayElement(ArrayElementCreateMessage *msg);
   ArrayElement(ArrayElementMigrateMessage *msg);
-  void finishConstruction(void);
-  void migrate(int where);
-  void finishMigration(void);
-  void exit(ArrayElementExitMessage *msg);
-  int getIndex(void) { return thisIndex; }
-  int getSize(void)  { return numElements; }
+
+private:
+  ArrayElement(void) {};
 
 protected:
+
+  // For Backward compatibility:
+  void finishConstruction(void) { finishConstruction(false); };
+
+  void finishConstruction(bool use_local_barrier);
+  void finishMigration(void);
+
   virtual int packsize(void) { return 0; }
   virtual void pack(void *) { return; }
+  void AtSync();
+  virtual void ResumeFromSync(void) {
+    CkPrintf("No ResumeFromSync() defined for this element!\n");
+  };
+
+  int thisIndex;
+  CkAID thisAID;
+  int numElements;
+
+public:
+  void migrate(int where);
+  void exit(ArrayElementExitMessage *msg);
+  int getIndex(void) { return thisIndex; }
+  int getSize(void)  { return numElements; }
 
+private:
   CkChareID arrayChareID;
   CkGroupID arrayGroupID;
   Array1D *thisArray;
-  CkAID thisAID;
-  int numElements;
-  int thisIndex;
 };
 
 enum {unknownPe = -1};
@@ -66,8 +91,9 @@ class ArrayMessage;
 class ArrayMigrateMessage;
 class ArrayElementAckMessage;
 
-class Array1D : public Group
-{
+class Array1D : public Group {
+friend class ArrayElement;
+
 public:
   static  CkGroupID CreateArray(int numElements,
                                CkGroupID mapID,
@@ -79,22 +105,47 @@ public:
   void send(ArrayMessage *msg, int index, EntryIndexType ei);
   void broadcast(ArrayMessage *msg, EntryIndexType ei);
   void RecvMapID(ArrayMap *mapPtr,int mapHandle);
-  void RecvElementID(int index, ArrayElement *elem, CkChareID handle);
+  void RecvElementID(int index, ArrayElement *elem, CkChareID handle,
+                    bool uses_barrier);
   void RecvForElement(ArrayMessage *msg);
   void RecvMigratedElement(ArrayMigrateMessage *msg);
   void RecvMigratedElementID(int index, ArrayElement *elem, CkChareID handle);
   void AckMigratedElement(ArrayElementAckMessage *msg);
-  void migrateMe(int index, int where);
   int array_size(void) { return numElements; };
   int num_local(void) { return numLocalElements; };
   int ckGetGroupId(void) { return thisgroup; }
   ArrayElement *getElement(int idx) { return elementIDs[idx].element; }
 
+#if CMK_LBDB_ON
+  static void staticMigrate(LDObjHandle _h, int _dest);
+  static void staticSetStats(LDOMHandle _h, int _state);
+  static void staticQueryLoad(LDOMHandle _h);
+  static void staticResumeFromSync(void* data);
+  static void staticRecvAtSync(void* data);
+#endif
+
   typedef enum {creating, here, moving_to, arriving, at} ElementState;
 
 private:
+  void migrateMe(int index, int where);
+
+#if CMK_LBDB_ON
+  void Migrate(LDObjHandle _h, int _dest);
+  void SetStats(LDOMHandle _h, int _state);
+  void QueryLoad(LDOMHandle _h);
+
+  void RegisterElementForSync(int index);
+  void AtSync(int index);
+  void ResumeFromSync(int index);
+  void RecvAtSync();
+#endif
 
   struct ElementIDs {
+    struct BarrierClientData {
+      Array1D *me;            
+      int index;
+    };
+
     ElementState state;
     int originalPE;
     int pe;
@@ -103,6 +154,12 @@ private:
     int cameFrom;
     int curHop;
     ArrayMigrateMessage *migrateMsg;
+#if CMK_LBDB_ON
+    LDObjHandle ldHandle;
+    bool uses_barrier;
+    LDBarrierClient barrierHandle;
+    BarrierClientData barrierData;
+#endif
   };
 
   int numElements;
@@ -115,6 +172,11 @@ private:
   ElementIDs *elementIDs;
   int elementIDsReported;
   int numLocalElements;
+
+#if CMK_LBDB_ON
+  LDOMHandle myHandle;
+  LBDatabase *the_lbdb;
+#endif
   PtrQ *bufferedForElement;
   PtrQ *bufferedMigrated;
 };
@@ -129,6 +191,7 @@ public:
   ChareIndexType elementChareType;
   EntryIndexType elementConstType;
   EntryIndexType elementMigrateType;
+  CkGroupID loadbalancer;
 };
 
 class ArrayMessage
@@ -158,6 +221,7 @@ public:
   int elementSize;
   void *elementData;
   int hopCount;
+  bool uses_barrier;
 
   static void *alloc(int msgnum, int size, int *array, int priobits);
   static void *pack(ArrayMigrateMessage *);
@@ -191,8 +255,7 @@ public:
   CkGroupID groupID;
 };
 
-class ArrayElementCreateMessage : public CMessage_ArrayElementCreateMessage
-{
+class ArrayElementCreateMessage : public CMessage_ArrayElementCreateMessage {
 public:
   int numElements;
   CkChareID arrayID;
@@ -201,8 +264,7 @@ public:
   int index;
 };
 
-class ArrayElementMigrateMessage : public CMessage_ArrayElementMigrateMessage
-{
+class ArrayElementMigrateMessage : public CMessage_ArrayElementMigrateMessage {
 public:
   int numElements;
   CkChareID arrayID;
diff --git a/src/ck-ldb/CentralLB.C b/src/ck-ldb/CentralLB.C
new file mode 100644 (file)
index 0000000..44f005f
--- /dev/null
@@ -0,0 +1,253 @@
+#include <charm++.h>
+#include <LBDatabase.h>
+#include "CentralLB.h"
+#include "CentralLB.def.h"
+
+CkGroupID loadbalancer;
+
+void CreateCentralLB()
+{
+  loadbalancer = CProxy_CentralLB::ckNew();
+}
+
+void CentralLB::staticMigrated(void* data, LDObjHandle h)
+{
+  CentralLB *me = static_cast<CentralLB*>(data);
+
+  me->Migrated(h);
+}
+
+void CentralLB::staticAtSync(void* data)
+{
+  CentralLB *me = static_cast<CentralLB*>(data);
+
+  me->AtSync();
+}
+
+CentralLB::CentralLB()
+{
+  step = 0;
+  theLbdb = CProxy_LBDatabase(lbdb).ckLocalBranch();
+  theLbdb->AddLocalBarrierReceiver(staticAtSync,static_cast<void*>(this));
+  theLbdb->NotifyMigrated(staticMigrated,static_cast<void*>(this));
+
+  stats_msg_count = 0;
+  statsMsgsList = new CLBStatsMsg*[CkNumPes()];
+  for(int i=0; i < CkNumPes(); i++)
+    statsMsgsList[i] = 0;
+
+  statsDataList = new LDStats[CkNumPes()];
+}
+
+CentralLB::~CentralLB()
+{
+  CkPrintf("Going away\n");
+}
+
+void CentralLB::AtSync()
+{
+  CkPrintf("[%d] CentralLB At Sync step %d!!!!\n",CkMyPe(),step);
+
+  if (!QueryBalanceNow(step)) {
+    MigrationDone();
+    return;
+  }
+
+  // Send stats
+  int sizes[2];
+  const int osz = sizes[0] = theLbdb->GetObjDataSz();
+  const int csz = sizes[1] = theLbdb->GetCommDataSz();
+  
+  CLBStatsMsg* msg = new(sizes,2) CLBStatsMsg;
+  msg->from_pe = CkMyPe();
+  msg->serial = rand();
+
+  msg->n_objs = osz;
+  theLbdb->GetObjData(msg->objData);
+  msg->n_comm = csz;
+  theLbdb->GetCommData(msg->commData);
+  theLbdb->ClearLoads();
+  CkPrintf("PE %d sending %d to ReceiveStats\n",CkMyPe(),msg->serial);
+  CProxy_CentralLB(thisgroup).ReceiveStats(msg,0);
+}
+
+void CentralLB::Migrated(LDObjHandle h)
+{
+  migrates_completed++;
+  CkPrintf("[%d] An object migrated! %d %d\n",
+          CkMyPe(),migrates_completed,migrates_expected);
+  if (migrates_completed == migrates_expected) {
+    MigrationDone();
+  }
+}
+
+void CentralLB::ReceiveStats(CLBStatsMsg *m)
+{
+  const int pe = m->from_pe;
+  CkPrintf("Stats msg received, %d %d %d %d %p\n",
+          pe,stats_msg_count,m->n_objs,m->serial,m);
+  if (statsMsgsList[pe] != 0) {
+    CkPrintf("*** Unexpected CLBStatsMsg in ReceiveStats from PE %d ***\n",
+            pe);
+  } else {
+    statsMsgsList[pe] = m;
+    statsDataList[pe].n_objs = m->n_objs;
+    statsDataList[pe].objData = m->objData;
+    statsDataList[pe].n_comm = m->n_comm;
+    statsDataList[pe].commData = m->commData;
+    stats_msg_count++;
+  }
+
+  const int clients = CkNumPes();
+  if (stats_msg_count == clients) {
+
+    CLBMigrateMsg* migrateMsg = Strategy(statsDataList,clients);
+    CProxy_CentralLB(thisgroup).ReceiveMigration(migrateMsg);
+
+    // Zero out data structures for next cycle
+    for(int i=0; i < clients; i++) {
+      delete statsMsgsList[i];
+      statsMsgsList[i]=0;
+    }
+    stats_msg_count=0;
+  }
+  
+}
+
+void CentralLB::ReceiveMigration(CLBMigrateMsg *m)
+{
+  CkPrintf("[%d] in ReceiveMigration %d moves\n",CkMyPe(),m->n_moves);
+  migrates_expected = 0;
+  for(int i=0; i < m->n_moves; i++) {
+    MigrateInfo& move = m->moves[i];
+    const int me = CkMyPe();
+    if (move.from_pe == me && move.to_pe != me) {
+      CkPrintf("[%d] migrating object to %d\n",move.from_pe,move.to_pe);
+      theLbdb->Migrate(move.obj,move.to_pe);
+    } else if (move.from_pe != me && move.to_pe == me) {
+      migrates_expected++;
+    }
+  }
+  if (migrates_expected == 0)
+    MigrationDone();
+  delete m;
+}
+
+
+void CentralLB::MigrationDone()
+{
+  migrates_completed = 0;
+  migrates_expected = -1;
+  // Increment to next step
+  step++;
+  theLbdb->ResumeClients();
+}
+
+CLBMigrateMsg* CentralLB::Strategy(LDStats* stats,int count)
+{
+  for(int j=0; j < count; j++) {
+    int i;
+    LDObjData *odata = stats[j].objData;
+    const int osz = stats[j].n_objs;
+
+    CkPrintf("------------- Object Data: PE %d: %d objects -------------\n",
+            j,osz);
+    for(i=0; i < osz; i++) {
+      CkPrintf("Object %d\n",i);
+      CkPrintf("     id = %d\n",odata[i].id.id[0]);
+      CkPrintf("  OM id = %d\n",odata[i].omID);
+      CkPrintf("    CPU = %f\n",odata[i].cpuTime);
+      CkPrintf("   Wall = %f\n",odata[i].wallTime);
+    }
+
+    LDCommData *cdata = stats[j].commData;
+    const int csz = stats[j].n_comm;
+
+    CkPrintf("------------- Comm Data: PE %d: %d records -------------\n",
+            i,csz);
+    for(i=0; i < csz; i++) {
+      CkPrintf("Object %d\n",i);
+      CkPrintf("    sender id = %d\n",cdata[i].sender);
+      CkPrintf("  receiver id = %d\n",cdata[i].receiver);
+      CkPrintf("     messages = %d\n",cdata[i].nMessages);
+      CkPrintf("        bytes = %d\n",cdata[i].nBytes);
+    }
+  }
+
+  int sizes=0;
+  CLBMigrateMsg* msg = new(&sizes,1) CLBMigrateMsg;
+  msg->n_moves = 0;
+
+  return msg;
+}
+
+void* CLBStatsMsg::alloc(int msgnum, size_t size, int* array, int priobits)
+{
+  int totalsize = size + array[0] * sizeof(LDObjData) 
+    + array[1] * sizeof(LDCommData);
+
+  CLBStatsMsg* ret =
+    static_cast<CLBStatsMsg*>(CkAllocMsg(msgnum,totalsize,priobits));
+
+  ret->objData = reinterpret_cast<LDObjData*>((reinterpret_cast<char*>(ret) 
+                                              + size));
+  ret->commData = reinterpret_cast<LDCommData*>(ret->objData + array[0]);
+
+  return static_cast<void*>(ret);
+}
+
+void* CLBStatsMsg::pack(CLBStatsMsg* m)
+{
+  m->objData = 
+    reinterpret_cast<LDObjData*>(reinterpret_cast<char*>(m->objData)
+      - reinterpret_cast<char*>(&m->objData));
+  m->commData = 
+    reinterpret_cast<LDCommData*>(reinterpret_cast<char*>(m->commData)
+      - reinterpret_cast<char*>(&m->commData));
+  return static_cast<void*>(m);
+}
+
+CLBStatsMsg* CLBStatsMsg::unpack(void *m)
+{
+  CLBStatsMsg* ret_val = static_cast<CLBStatsMsg*>(m);
+
+  ret_val->objData = 
+    reinterpret_cast<LDObjData*>(reinterpret_cast<char*>(&ret_val->objData)
+      + reinterpret_cast<size_t>(ret_val->objData));
+  ret_val->commData = 
+    reinterpret_cast<LDCommData*>(reinterpret_cast<char*>(&ret_val->commData)
+      + reinterpret_cast<size_t>(ret_val->commData));
+  return ret_val;
+}
+
+void* CLBMigrateMsg::alloc(int msgnum, size_t size, int* array, int priobits)
+{
+  int totalsize = size + array[0] * sizeof(CentralLB::MigrateInfo);
+
+  CLBMigrateMsg* ret =
+    static_cast<CLBMigrateMsg*>(CkAllocMsg(msgnum,totalsize,priobits));
+
+  ret->moves = reinterpret_cast<CentralLB::MigrateInfo*>
+    (reinterpret_cast<char*>(ret)+ size);
+
+  return static_cast<void*>(ret);
+}
+
+void* CLBMigrateMsg::pack(CLBMigrateMsg* m)
+{
+  m->moves = reinterpret_cast<CentralLB::MigrateInfo*>
+    (reinterpret_cast<char*>(m->moves) - reinterpret_cast<char*>(&m->moves));
+
+  return static_cast<void*>(m);
+}
+
+CLBMigrateMsg* CLBMigrateMsg::unpack(void *m)
+{
+  CLBMigrateMsg* ret_val = static_cast<CLBMigrateMsg*>(m);
+
+  ret_val->moves = reinterpret_cast<CentralLB::MigrateInfo*>
+    (reinterpret_cast<char*>(&ret_val->moves) 
+     + reinterpret_cast<size_t>(ret_val->moves));
+
+  return ret_val;
+}
diff --git a/src/ck-ldb/CentralLB.ci b/src/ck-ldb/CentralLB.ci
new file mode 100644 (file)
index 0000000..ad96881
--- /dev/null
@@ -0,0 +1,16 @@
+module CentralLB {
+
+extern module LBDatabase;
+
+readonly CkGroupID loadbalancer;
+
+message[varsize] CLBStatsMsg;
+message[varsize] CLBMigrateMsg;
+
+group CentralLB {
+  entry void CentralLB(void);  
+  entry void ReceiveStats(CLBStatsMsg*);
+  entry void ReceiveMigration(CLBMigrateMsg*); 
+};
+
+};
diff --git a/src/ck-ldb/CentralLB.h b/src/ck-ldb/CentralLB.h
new file mode 100644 (file)
index 0000000..10844b5
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef CENTRALLB_H
+#define CENTRALLB_H
+
+#include <LBDatabase.h>
+#include "CentralLB.decl.h"
+
+
+void CreateCentralLB();
+
+class CLBStatsMsg;
+class CLBMigrateMsg;
+
+class CentralLB : public Group
+{
+public:
+  CentralLB();
+  ~CentralLB();
+  static void staticAtSync(void*);
+  void AtSync(void); // Everything is at the PE barrier
+
+  void ReceiveStats(CLBStatsMsg *);            // Receive stats on PE 0
+  void ReceiveMigration(CLBMigrateMsg *);      // Receive migration data
+
+  // Migrated-element callback
+  static void staticMigrated(void* me, LDObjHandle h);
+  void Migrated(LDObjHandle h);
+
+  void MigrationDone(void);  // Call when migration is complete
+
+  struct MigrateInfo {  // Used in CLBMigrateMsg
+    LDObjHandle obj;
+    int from_pe;
+    int to_pe;
+  };
+
+  struct LDStats {  // Passed to Strategy
+    int n_objs;
+    LDObjData* objData;
+    int n_comm;
+    LDCommData* commData;
+  };
+
+protected:
+  virtual bool QueryBalanceNow(int) { return true; };  
+  virtual CLBMigrateMsg* Strategy(LDStats* stats,int count);
+
+private:  
+  int step;
+  LBDatabase* theLbdb;
+  int stats_msg_count;
+  CLBStatsMsg** statsMsgsList;
+  LDStats* statsDataList;
+  int migrates_completed;
+  int migrates_expected;
+};
+
+class CLBStatsMsg : public CMessage_CLBStatsMsg {
+public:
+  int from_pe;
+  int serial;
+  int n_objs;
+  LDObjData *objData;
+  int n_comm;
+  LDCommData *commData;
+
+  // Other methods & data members 
+
+  static void* alloc(int msgnum, size_t size, int* array, int priobits); 
+  static void* pack(CLBStatsMsg* in); 
+  static CLBStatsMsg* unpack(void* in); 
+}; 
+
+class CLBMigrateMsg : public CMessage_CLBMigrateMsg {
+public:
+  int n_moves;
+  CentralLB::MigrateInfo* moves;
+
+  // Other methods & data members 
+
+  static void* alloc(int msgnum, size_t size, int* array, int priobits); 
+  static void* pack(CLBMigrateMsg* in); 
+  static CLBMigrateMsg* unpack(void* in); 
+}; 
+
+#endif /* CENTRALLB_H */
diff --git a/src/ck-ldb/LBDB.C b/src/ck-ldb/LBDB.C
new file mode 100644 (file)
index 0000000..fd33c25
--- /dev/null
@@ -0,0 +1,268 @@
+#include <converse.h>
+
+#if CMK_LBDB_ON
+
+#include <iostream.h>
+#include "LBDB.h"
+
+struct MigrateCB;
+
+#if CMK_STL_USE_DOT_H
+template class vector<LBOM*>;
+template class vector<LBObj*>;
+template class vector<LBDB::MigrateCB*>;
+template class vector<LocalBarrier::client*>;
+template class vector<LocalBarrier::receiver*>;
+#else
+template class std::vector<LBOM*>;
+template class std::vector<LBObj*>;
+template class std::vector<LBDB::MigrateCB*>;
+template class std::vector<LocalBarrier::client*>;
+template class std::vector<LocalBarrier::receiver*>;
+#endif
+
+/*************************************************************
+ * LBDB Code
+ *************************************************************/
+
+LDOMHandle LBDB::AddOM(LDOMid _userID, void* _userData, 
+                      LDCallbacks _callbacks)
+{
+  LDOMHandle newhandle;
+
+  newhandle.ldb.handle = static_cast<void *>(this);
+  newhandle.user_ptr = _userData;
+  newhandle.id = _userID;
+
+  LBOM* om = new LBOM(this,_userID,_userData,_callbacks);
+  if (om != NULL) {
+    newhandle.handle = oms.size();
+    oms.push_back(om);
+  } else newhandle.handle = -1;
+  om->DepositHandle(newhandle);
+  omCount++;
+  return newhandle;
+}
+
+LDObjHandle LBDB::AddObj(LDOMHandle _h, LDObjid _id,
+                        void *_userData, bool _migratable)
+{
+  LDObjHandle newhandle;
+
+  newhandle.omhandle = _h;
+  newhandle.user_ptr = _userData;
+  newhandle.id = _id;
+  
+  LBObj *obj = new LBObj(this,_h,_id,_userData,_migratable);
+  if (obj != NULL) {
+    newhandle.handle = objs.size();
+    objs.push_back(obj);
+  } else {
+    newhandle.handle = -1;
+  }
+  obj->DepositHandle(newhandle);
+  objCount++;
+  return newhandle;
+}
+
+void LBDB::UnregisterObj(LDObjHandle _h)
+{
+  objs[_h.handle]->registered=false;
+}
+
+void LBDB::RegisteringObjects(LDOMHandle _h)
+{
+  LBOM* om = oms[_h.handle];
+  if (!om->RegisteringObjs()) {
+    if (oms_registering == 0)
+      localBarrier.TurnOff();
+    oms_registering++;
+    om->SetRegisteringObjs(true);
+  }
+}
+
+void LBDB::DoneRegisteringObjects(LDOMHandle _h)
+{
+  LBOM* om = oms[_h.handle];
+  if (om->RegisteringObjs()) {
+    oms_registering--;
+    if (oms_registering == 0)
+      localBarrier.TurnOn();
+    om->SetRegisteringObjs(false);
+  }
+}
+
+void LBDB::ClearLoads(void)
+{
+  int i;
+  for(i=0; i < objCount; i++)
+    if (objs[i]->registered)
+    {
+      objs[i]->data.wallTime = 
+       objs[i]->data.cpuTime = 0.;
+    }
+}
+
+int LBDB::ObjDataCount()
+{
+  int nitems=0;
+  int i;
+  for(i=0; i < objCount; i++)
+    if (objs[i]->registered)
+      nitems++;
+  return nitems;
+}
+
+void LBDB::GetObjData(LDObjData *dp)
+{
+  for(ObjList::iterator ol = objs.begin(); ol != objs.end(); ol++)
+    if ((*ol)->registered)
+      *dp++ = (*ol)->ObjData();
+}
+
+void LBDB::Migrate(LDObjHandle h, int dest)
+{
+  if (h.handle > objCount)
+    CmiPrintf("[%d] Handle %d out of range 0-%d\n",CmiMyPe(),h.handle,objCount);
+  else if (!objs[h.handle]->registered)
+    CmiPrintf("[%d] Handle %d no longer registered, range 0-%d\n",
+           CmiMyPe(),h.handle,objCount);
+
+  if ((h.handle < objCount) && (objs[h.handle]->registered)) {
+    LBOM *const om = oms[objs[h.handle]->parentOM.handle];
+    om->Migrate(h, dest);
+  }
+  return;
+}
+
+void LBDB::Migrated(LDObjHandle h)
+{
+  // Object migrated, inform load balancers
+
+  for(int i=0; i < migrateCBList.size(); i++)
+    (migrateCBList[i]->fn)(migrateCBList[i]->data,h);
+  
+}
+
+void LBDB::NotifyMigrated(LDMigratedFn fn, void* data)
+{
+  // Save migration function
+  MigrateCB* callbk = new MigrateCB;
+
+  callbk->fn = fn;
+  callbk->data = data;
+  migrateCBList.push_back(callbk);
+}
+
+void LBDB::DumpDatabase()
+{
+#ifdef DEBUG  
+  CmiPrintf("Database contains %d object managers\n",omCount);
+  CmiPrintf("Database contains %d objects\n",objCount);
+#endif
+}
+
+LDBarrierClient LocalBarrier::AddClient(LDResumeFn fn, void* data)
+{
+  CmiPrintf("[%d] LocalBarrier Adding client\n",CmiMyPe());
+  client* new_client = new client;
+  new_client->fn = fn;
+  new_client->data = data;
+  new_client->refcount = cur_refcount;
+
+  LDBarrierClient ret_val;
+  ret_val.serial = max_client;
+  clients.push_back(new_client);
+  max_client++;
+
+  client_count++;
+
+  return ret_val;
+}
+
+void LocalBarrier::RemoveClient(LDBarrierClient c)
+{
+  CmiPrintf("[%d] LocalBarrier Removing client\n",CmiMyPe());
+  const int cnum = c.serial;
+  if (cnum < max_client && clients[cnum] != 0) {
+    delete clients[cnum];
+    clients[cnum] = 0;
+    client_count--;
+  }
+}
+
+LDBarrierReceiver LocalBarrier::AddReceiver(LDBarrierFn fn, void* data)
+{
+  receiver* new_receiver = new receiver;
+  new_receiver->fn = fn;
+  new_receiver->data = data;
+
+  LDBarrierReceiver ret_val;
+  ret_val.serial = max_receiver;
+  receivers.push_back(new_receiver);
+  max_receiver++;
+
+  return ret_val;
+}
+
+void LocalBarrier::RemoveReceiver(LDBarrierReceiver c)
+{
+  const int cnum = c.serial;
+  if (cnum < max_receiver && receivers[cnum] != 0) {
+    delete receivers[cnum];
+    receivers[cnum] = 0;
+  }
+}
+
+void LocalBarrier::AtBarrier(LDBarrierClient h)
+{
+  clients[h.serial]->refcount++;
+  at_count++;
+  CheckBarrier();
+}
+
+void LocalBarrier::CheckBarrier()
+{
+  if (!on) return;
+
+  if (at_count >= client_count) {
+    bool at_barrier = false;
+
+    for(int i=0; i < max_client; i++)
+      if (clients[i] != 0 && clients[i]->refcount >= cur_refcount)
+       at_barrier = true;
+
+    if (at_barrier) {
+      at_count -= client_count;
+      cur_refcount++;
+      CallReceivers();
+    }
+  }
+}
+
+void LocalBarrier::CallReceivers(void)
+{
+  CmiPrintf("All at barrier, calling receviers for %d clients\n",
+           client_count);
+  bool called_receiver=false;
+
+  for(int i=0; i < max_receiver; i++)
+    if (receivers[i] != 0) {
+      receivers[i]->fn(receivers[i]->data);
+      called_receiver = true;
+    }
+
+  if (!called_receiver)
+    ResumeClients();
+  
+}
+
+void LocalBarrier::ResumeClients(void)
+{
+  CmiPrintf("[%d] Resuming %d clients\n",CmiMyPe(),client_count);
+  for(int i=0; i < max_client; i++)
+    if (clients[i] != 0) 
+      clients[i]->fn(clients[i]->data);
+}
+
+#endif // CMK_LBDB_ON
diff --git a/src/ck-ldb/LBDB.h b/src/ck-ldb/LBDB.h
new file mode 100644 (file)
index 0000000..228c630
--- /dev/null
@@ -0,0 +1,143 @@
+#ifndef LBDB_H
+#define LBDB_H
+
+#if CMK_STL_USE_DOT_H
+#include <vector.h>
+#else  // CMK_STL_NO_DOT_H
+#include <vector>
+#endif
+
+#include "lbdb.h"
+
+#include "LBObj.h"
+#include "LBOM.h"
+
+class LocalBarrier {
+friend class LBDB;
+public:
+  LocalBarrier() { cur_refcount = 1; client_count = 0; max_client = 0;
+                   max_receiver= 0; at_count = 0; on = false; };
+  ~LocalBarrier() { };
+
+  LDBarrierClient AddClient(LDResumeFn fn, void* data);
+  void RemoveClient(LDBarrierClient h);
+  LDBarrierReceiver AddReceiver(LDBarrierFn fn, void* data);
+  void RemoveReceiver(LDBarrierReceiver h);
+  void AtBarrier(LDBarrierClient h);
+  void TurnOn() { on = true; CheckBarrier(); };
+  void TurnOff() { on = false; };
+
+private:
+  void CallReceivers(void);
+  void CheckBarrier();
+  void ResumeClients(void);
+
+  struct client {
+    void* data;
+    LDResumeFn fn;
+    int refcount;
+  };
+   struct receiver {
+    void* data;
+    LDBarrierFn fn;
+  };
+
+#if CMK_STL_USE_DOT_H
+  vector<client*> clients;
+  vector<receiver*> receivers;
+#else
+  std::vector<client*> clients;
+  std::vector<receiver*> receivers;
+#endif
+
+  int cur_refcount;
+  int max_client;
+  int client_count;
+  int max_receiver;
+  int at_count;
+  bool on;
+};
+
+class LBDB {
+public:
+  LBDB() {
+    statsAreOn = false;
+    omCount = objCount = oms_registering = 0;
+  }
+
+  ~LBDB() { }
+
+  void insert(LBOM *om);
+
+  LDOMHandle AddOM(LDOMid _userID, void* _userData, 
+                  LDCallbacks _callbacks);
+  LDObjHandle AddObj(LDOMHandle _h, LDObjid _id, void *_userData,
+                    bool _migratable);
+  void UnregisterObj(LDObjHandle _h);
+
+  void RegisteringObjects(LDOMHandle _h);
+  void DoneRegisteringObjects(LDOMHandle _h);
+
+  LBOM *LbOM(LDOMHandle h) { return oms[h.handle]; };
+  LBObj *LbObj(LDObjHandle h) { return objs[h.handle]; };
+  void DumpDatabase(void);
+  void TurnStatsOn(void) { statsAreOn = true; };
+  void TurnStatsOff(void) { statsAreOn = false; };
+  bool StatsOn(void) { return statsAreOn; };
+  int ObjDataCount();
+  void GetObjData(LDObjData *data);
+  LDObjData *FetchData(int *nitems);
+  void Migrate(LDObjHandle h, int dest);
+  void Migrated(LDObjHandle h);
+  void NotifyMigrated(LDMigratedFn fn, void* data);
+  void ClearLoads(void);
+  
+  LDBarrierClient AddLocalBarrierClient(LDResumeFn fn, void* data) { 
+    return localBarrier.AddClient(fn,data);
+  };
+
+  void RemoveLocalBarrierClient(LDBarrierClient h) {
+    localBarrier.RemoveClient(h);
+  };
+  LDBarrierReceiver AddLocalBarrierReceiver(LDBarrierFn fn, void* data) {
+    return localBarrier.AddReceiver(fn,data);
+  };
+  void RemoveLocalBarrierReceiver(LDBarrierReceiver h) {
+    localBarrier.RemoveReceiver(h);
+  };
+  void AtLocalBarrier(LDBarrierClient h) {
+    localBarrier.AtBarrier(h);
+  };
+  void ResumeClients() {
+    localBarrier.ResumeClients();
+  };
+
+private:
+  struct MigrateCB {
+    LDMigratedFn fn;
+    void* data;
+  };
+
+#if CMK_STL_USE_DOT_H
+  typedef vector<LBOM*> OMList;
+  typedef vector<LBObj*> ObjList;
+  typedef vector<MigrateCB*> MigrateCBList;
+#else
+  typedef std::vector<LBOM*> OMList;
+  typedef std::vector<LBObj*> ObjList;
+  typedef std::vector<MigrateCB*> MigrateCBList;
+#endif
+
+  OMList oms;
+  int omCount;
+  int oms_registering;
+  ObjList objs;
+  int objCount;
+  bool statsAreOn;
+  MigrateCBList migrateCBList;
+
+  LocalBarrier localBarrier;
+};
+
+#endif
+
diff --git a/src/ck-ldb/LBDatabase.C b/src/ck-ldb/LBDatabase.C
new file mode 100644 (file)
index 0000000..c6bb446
--- /dev/null
@@ -0,0 +1,20 @@
+#include <converse.h>
+
+#if CMK_LBDB_ON
+
+/*
+ * This C++ file contains the Charm stub functions
+ */
+
+#include "LBDatabase.h"
+#include "LBDatabase.def.h"
+
+CkGroupID lbdb;
+
+void CreateLBDatabase()
+{
+  lbdb = CProxy_LBDatabase::ckNew();
+  CkPrintf("New database created\n");
+}
+
+#endif // CMK_LBDB_ON
diff --git a/src/ck-ldb/LBDatabase.ci b/src/ck-ldb/LBDatabase.ci
new file mode 100644 (file)
index 0000000..d6402ef
--- /dev/null
@@ -0,0 +1,9 @@
+module LBDatabase {
+
+readonly CkGroupID lbdb;
+
+group LBDatabase {
+  entry void LBDatabase(void);  
+};
+
+};
diff --git a/src/ck-ldb/LBDatabase.h b/src/ck-ldb/LBDatabase.h
new file mode 100644 (file)
index 0000000..1471ad1
--- /dev/null
@@ -0,0 +1,112 @@
+#ifndef LBDATABASE_H
+#define LBDATABASE_H
+
+#include "lbdb.h"
+#include "LBDatabase.decl.h"
+
+void CreateLBDatabase();
+
+class LBDatabase : public Group {
+public:
+  LBDatabase(void) {
+    myLDHandle = LDCreate();  
+    CkPrintf("Hi from LBDatabase1D[%d] %d\n",CkMyPe(),thisgroup);
+  };
+
+  /*
+   * Calls from object managers to load database
+   */
+  LDOMHandle RegisterOM(LDOMid userID, void *userptr, LDCallbacks cb) {
+    return LDRegisterOM(myLDHandle,userID, userptr, cb);
+  };
+
+  void RegisteringObjects(LDOMHandle _om) {
+    LDRegisteringObjects(_om);
+  };
+
+  void DoneRegisteringObjects(LDOMHandle _om) {
+    LDDoneRegisteringObjects(_om);
+  };
+
+  LDObjHandle RegisterObj(LDOMHandle h, LDObjid id,
+                         void *userptr,int migratable) {
+    return LDRegisterObj(h,id,userptr,migratable);
+  };
+
+  void UnregisterObj(LDObjHandle h) { LDUnregisterObj(h); };
+
+  void ObjTime(LDObjHandle h, double walltime, double cputime) {
+    LDObjTime(h,walltime,cputime);
+  };
+
+  void ObjectStart(LDObjHandle _h) { LDObjectStart(_h); };
+  void ObjectStop(LDObjHandle _h) { LDObjectStop(_h); };
+
+  void Message(LDObjHandle from, LDOMid toOM, LDObjid *toID, int bytes) {
+    LDMessage(from,toOM,toID,bytes);
+  };
+
+  void EstObjLoad(LDObjHandle h, double load) { LDEstObjLoad(h,load); };
+  void NonMigratable(LDObjHandle h) { LDNonMigratable(h); };
+  void Migratable(LDObjHandle h) { LDMigratable(h); };
+  void DumpDatabase(void) { LDDumpDatabase(myLDHandle); };
+
+  /*
+   * Calls from load balancer to load database
+   */  
+  void NotifyMigrated(LDMigratedFn fn, void *data) 
+  {
+    LDNotifyMigrated(myLDHandle,fn,data);
+  };
+  void CollectStatsOn(void) { LDCollectStatsOn(myLDHandle); };
+  void CollectStatsOff(void) { LDCollectStatsOff(myLDHandle); };
+  void QueryEstLoad(void) { LDQueryEstLoad(myLDHandle); };
+
+  int GetObjDataSz(void) { return LDGetObjDataSz(myLDHandle); };
+  void GetObjData(LDObjData *data) { LDGetObjData(myLDHandle,data); };
+  int GetCommDataSz(void) { return LDGetCommDataSz(myLDHandle); };
+  void GetCommData(LDCommData *data) { LDGetCommData(myLDHandle,data); };
+
+  void BackgroundLoad(double *walltime, double *cputime) {
+    LDBackgroundLoad(myLDHandle,walltime,cputime);
+  }
+
+  void IdleTime(double *walltime, double *cputime) {
+    LDIdleTime(myLDHandle,walltime,cputime);
+  };
+
+  void TotalTime(double *walltime, double *cputime) {
+    LDTotalTime(myLDHandle,walltime,cputime);
+  }
+
+  void ClearLoads(void) { LDClearLoads(myLDHandle); };
+  void Migrate(LDObjHandle h, int dest) { LDMigrate(h,dest); };
+
+  void Migrated(LDObjHandle h) { LDMigrated(h); };
+
+  LDBarrierClient AddLocalBarrierClient(LDResumeFn fn, void* data) {
+    return LDAddLocalBarrierClient(myLDHandle,fn,data);
+  };
+
+  void RemoveLocalBarrierClient(LDBarrierClient h) {
+    LDRemoveLocalBarrierClient(myLDHandle, h);
+  };
+
+  LDBarrierReceiver AddLocalBarrierReceiver(LDBarrierFn fn, void *data) {
+    return LDAddLocalBarrierReceiver(myLDHandle,fn,data);
+  };
+
+  void RemoveLocalBarrierReceiver(LDBarrierReceiver h) {
+    LDRemoveLocalBarrierReceiver(myLDHandle,h);
+  };
+
+  void AtLocalBarrier(LDBarrierClient h) { LDAtLocalBarrier(myLDHandle,h); };
+  void ResumeClients() { LDResumeClients(myLDHandle); }
+
+private:
+  LDHandle myLDHandle;
+
+};
+
+#endif /* LDATABASE_H */
diff --git a/src/ck-ldb/LBOM.h b/src/ck-ldb/LBOM.h
new file mode 100644 (file)
index 0000000..56b0b5b
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef LBOM_H
+#define LBOM_H
+
+#include "lbdb.h"
+#include "LBObj.h"
+
+class LBDB;
+
+class LBOM
+{
+friend class LBDB;
+
+public:
+  LDOMid id() { return myid; };
+
+private:
+  LBOM() { };
+
+  LBOM(LBDB *_parent, LDOMid _id,
+       void *_userData, LDCallbacks _callbacks)  {
+    parent = _parent;
+    myid = _id;
+    userData = _userData;
+    callbacks = _callbacks;
+    registering_objs = false;
+  };
+  ~LBOM() { }
+
+  void DepositHandle(LDOMHandle _h) { myhandle = _h; };
+  void Migrate(LDObjHandle _h, int dest) { callbacks.migrate(_h,dest); };
+  bool RegisteringObjs() { return registering_objs; };
+  void SetRegisteringObjs(bool _set) { registering_objs = _set; };
+
+  LBDB *parent;
+  LDOMid myid;
+  LDOMHandle myhandle;
+  void *userData;
+  LDCallbacks callbacks;
+  bool registering_objs;
+
+};
+
+#endif
diff --git a/src/ck-ldb/LBObj.C b/src/ck-ldb/LBObj.C
new file mode 100644 (file)
index 0000000..0d6f6f4
--- /dev/null
@@ -0,0 +1,44 @@
+#include <converse.h>
+
+#if CMK_LBDB_ON
+
+
+#include "LBObj.h"
+#include "LBOM.h"
+#include "LBDB.h"
+
+/*************************************************************
+ * LBObj Object-data Code
+ *************************************************************/
+
+void LBObj::Clear(void)
+{
+  data.handle = myhandle;
+  data.id = myid;
+  data.omHandle = parentOM;
+  data.omID = parentDB->LbOM(parentOM)->id();
+  data.cpuTime = 0.;
+  data.wallTime = 0.;
+}
+
+void LBObj::IncrementTime(double walltime, double cputime)
+{
+  data.wallTime += walltime;
+  data.cpuTime += cputime;
+}
+
+void LBObj::StartTimer(void)
+{
+  startWTime = CmiWallTimer();
+  startCTime = CmiCpuTimer();
+}
+
+void LBObj::StopTimer(double* walltime, double* cputime)
+{
+  const double endWTime = CmiWallTimer();
+  const double endCTime = CmiCpuTimer();
+  *walltime = endWTime - startWTime;
+  *cputime = endCTime - startCTime;
+}
+
+#endif // CMK_LBDB_ON
diff --git a/src/ck-ldb/LBObj.h b/src/ck-ldb/LBObj.h
new file mode 100644 (file)
index 0000000..c7beb74
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef LBOBJ_H
+#define LBOBJ_H
+
+#include "lbdb.h"
+
+class LBObj
+{
+friend class LBDB;
+
+public:
+  LBObj(LBDB* _parentDB, LDOMHandle _omhandle, LDObjid _id,
+       void *_userData = 0, bool _migratable=true) {
+    parentDB = _parentDB;
+    parentOM = _omhandle;
+    myid = _id;
+    userData = _userData;
+    migratable = _migratable;
+    registered = false;
+  };
+
+  ~LBObj() { };
+
+  void DepositHandle(LDObjHandle _h) {
+    myhandle = _h;
+    data.handle = myhandle;
+    data.id = myid;
+    data.omHandle = _h.omhandle;
+    data.omID = _h.omhandle.id;
+    data.cpuTime = 0.;
+    data.wallTime = 0.;
+    registered = true;
+  };
+
+  void Clear(void);
+  void IncrementTime(double walltime, double cputime);
+  void StartTimer(void);
+  void StopTimer(double* walltime, double* cputime);
+
+private:
+  LDObjData ObjData() { return data; };
+
+  LBDB* parentDB;
+  LDOMHandle parentOM;
+  LDObjHandle myhandle;
+  LDObjid myid;
+  void *userData;
+  bool migratable;
+  LDObjData data;
+  double startWTime;
+  double startCTime;
+  bool registered;
+};
+
+#endif
diff --git a/src/ck-ldb/RandCentLB.C b/src/ck-ldb/RandCentLB.C
new file mode 100644 (file)
index 0000000..1964538
--- /dev/null
@@ -0,0 +1,75 @@
+#include <charm++.h>
+
+#if CMK_STL_USE_DOT_H
+#include <deque.h>
+#include <queue.h>
+#else
+#include <deque>
+#include <queue>
+#endif
+
+#include "RandCentLB.h"
+#include "RandCentLB.def.h"
+
+#if CMK_STL_USE_DOT_H
+template class deque<CentralLB::MigrateInfo>;
+#else
+template class std::deque<CentralLB::MigrateInfo>;
+#endif
+
+void CreateRandCentLB()
+{
+  CkPrintf("[%d] creating RandCentLB %d\n",CkMyPe(),loadbalancer);
+  loadbalancer = CProxy_RandCentLB::ckNew();
+  CkPrintf("[%d] created RandCentLB %d\n",CkMyPe(),loadbalancer);
+}
+
+RandCentLB::RandCentLB()
+{
+  CkPrintf("[%d] RandCentLB created\n",CkMyPe());
+}
+
+bool RandCentLB::QueryBalanceNow(int step)
+{
+  CkPrintf("[%d] Balancing on step %d\n",CkMyPe(),step);
+  return true;
+}
+
+CLBMigrateMsg* RandCentLB::Strategy(CentralLB::LDStats* stats, int count)
+{
+  CkPrintf("[%d] RandCentLB strategy\n",CkMyPe());
+
+#if CMK_STL_USE_DOT_H
+  queue<MigrateInfo> migrateInfo;
+#else
+  std::queue<MigrateInfo> migrateInfo;
+#endif
+
+  for(int pe=0; pe < count; pe++) {
+    CkPrintf("[%d] PE %d : %d Objects : %d Communication\n",
+            CkMyPe(),pe,stats[pe].n_objs,stats[pe].n_comm);
+    for(int obj=0; obj < stats[pe].n_objs; obj++) {
+      const int dest = (int)((static_cast<double>(random()) * count) 
+                            / RAND_MAX);
+      if (dest != pe) {
+       CkPrintf("[%d] Obj %d migrating from %d to %d\n",
+                CkMyPe(),obj,pe,dest);
+       MigrateInfo migrateMe;
+       migrateMe.obj = stats[pe].objData[obj].handle;
+       migrateMe.from_pe = pe;
+       migrateMe.to_pe = dest;
+       migrateInfo.push(migrateMe);
+      }
+    }
+  }
+
+  int migrate_count=migrateInfo.size();
+  CLBMigrateMsg* msg = new(&migrate_count,1) CLBMigrateMsg;
+  msg->n_moves = migrate_count;
+  for(int i=0; i < migrate_count; i++) {
+    msg->moves[i] = migrateInfo.front();
+    migrateInfo.pop();
+  }
+
+  return msg;
+};
diff --git a/src/ck-ldb/RandCentLB.ci b/src/ck-ldb/RandCentLB.ci
new file mode 100644 (file)
index 0000000..caec764
--- /dev/null
@@ -0,0 +1,9 @@
+module RandCentLB {
+
+extern module CentralLB;
+
+group RandCentLB : CentralLB {
+  entry void RandCentLB(void);  
+};
+
+};
diff --git a/src/ck-ldb/RandCentLB.h b/src/ck-ldb/RandCentLB.h
new file mode 100644 (file)
index 0000000..1a21caf
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _RANDCENTLB_H_
+#define _RANDCENTLB_H_
+
+#include "CentralLB.h"
+#include "RandCentLB.decl.h"
+
+void CreateRandCentLB();
+
+class RandCentLB : public CentralLB {
+public:
+  RandCentLB();
+private:
+  bool QueryBalanceNow(int step);
+  CLBMigrateMsg* Strategy(CentralLB::LDStats* stats, int count);
+};
+
+#endif /* _RANDCENTLB_H_ */
diff --git a/src/ck-ldb/lbdb.C b/src/ck-ldb/lbdb.C
new file mode 100644 (file)
index 0000000..7a03752
--- /dev/null
@@ -0,0 +1,203 @@
+#include <converse.h>
+
+#if CMK_LBDB_ON
+
+#include "lbdb.h"
+#include "LBObj.h"
+#include "LBOM.h"
+#include "LBDB.h"
+  
+extern "C" LDHandle LDCreate(void)
+{
+  LDHandle h;
+  h.handle = static_cast<void*>(new LBDB);
+  return h;
+}
+
+extern "C" LDOMHandle LDRegisterOM(LDHandle _db, LDOMid _userID,
+                                  void *_userptr, LDCallbacks _callbacks)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+  return db->AddOM(_userID, _userptr, _callbacks);
+}
+
+extern "C" void LDRegisteringObjects(LDOMHandle _h)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.ldb.handle);
+  db->RegisteringObjects(_h);
+}
+
+extern "C" void LDDoneRegisteringObjects(LDOMHandle _h)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.ldb.handle);
+  db->DoneRegisteringObjects(_h);
+}
+
+extern "C" LDObjHandle LDRegisterObj(LDOMHandle _h, LDObjid _id, 
+                                      void *_userData, int _migratable)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.ldb.handle);
+  return db->AddObj(_h, _id, _userData, static_cast<bool>(_migratable));
+}
+
+extern "C" void LDUnregisterObj(LDObjHandle _h)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.omhandle.ldb.handle);
+  db->UnregisterObj(_h);
+  return;
+}
+
+extern "C" void LDObjTime(LDObjHandle _h,
+                           double walltime, double cputime)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.omhandle.ldb.handle);
+  LBObj *const obj = db->LbObj(_h);
+  obj->IncrementTime(walltime,cputime);
+}
+  
+extern "C" void LDDumpDatabase(LDHandle _db)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+  db->DumpDatabase();
+}
+
+void LDNotifyMigrated(LDHandle _db, LDMigratedFn fn, void* data)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+  db->NotifyMigrated(fn,data);
+}
+
+extern "C" void LDCollectStatsOn(LDHandle _db)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+  db->TurnStatsOn();
+}
+
+extern "C" void LDCollectStatsOff(LDHandle _db)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+  db->TurnStatsOff();
+}
+
+extern "C" void LDObjectStart(LDObjHandle _h)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.omhandle.ldb.handle);
+  if (db->StatsOn()) {
+    LBObj *const obj = db->LbObj(_h);
+    obj->StartTimer();
+  }
+}
+
+extern "C" void LDObjectStop(LDObjHandle _h)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.omhandle.ldb.handle);
+  if (db->StatsOn()) {
+    LBObj *const obj = db->LbObj(_h);
+    double walltime, cputime;
+    obj->StopTimer(&walltime,&cputime);
+    obj->IncrementTime(walltime,cputime);
+  }
+}
+
+extern "C" void LDClearLoads(LDHandle _db)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  db->ClearLoads();
+}
+
+extern "C" int LDGetObjDataSz(LDHandle _db)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  return db->ObjDataCount();
+}
+
+extern "C" void LDGetObjData(LDHandle _db, LDObjData *data)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  db->GetObjData(data);
+}
+
+extern "C" int LDGetCommDataSz(LDHandle _db)
+{
+  /*
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  return db->objDataCount();
+  */
+
+  return 0;
+}
+
+extern "C" void LDGetCommData(LDHandle _db, LDCommData *data)
+{
+  /*
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  db->getObjData(data);
+  */
+  return;
+}
+
+extern "C" void LDMigrate(LDObjHandle _h, int dest)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.omhandle.ldb.handle);
+
+  db->Migrate(_h,dest);
+}
+
+extern "C" void LDMigrated(LDObjHandle _h)
+{
+  LBDB *const db = static_cast<LBDB*>(_h.omhandle.ldb.handle);
+
+  db->Migrated(_h);
+}
+
+extern "C" LDBarrierClient 
+LDAddLocalBarrierClient(LDHandle _db, LDResumeFn fn, void* data)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  return db->AddLocalBarrierClient(fn,data);
+}
+
+extern "C" void LDRemoveLocalBarrierClient(LDHandle _db, LDBarrierClient h)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  db->RemoveLocalBarrierClient(h);
+}
+
+extern "C" LDBarrierReceiver 
+LDAddLocalBarrierReceiver(LDHandle _db,LDBarrierFn fn, void* data)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  return db->AddLocalBarrierReceiver(fn,data);
+}
+
+extern "C" void 
+LDRemoveLocalBarrierReceiver(LDHandle _db,LDBarrierReceiver h)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  db->RemoveLocalBarrierReceiver(h);
+}
+
+extern "C" void LDAtLocalBarrier(LDHandle _db, LDBarrierClient h)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  db->AtLocalBarrier(h);
+}
+
+extern "C" void LDResumeClients(LDHandle _db)
+{
+  LBDB *const db = static_cast<LBDB*>(_db.handle);
+
+  db->ResumeClients();
+}
+
+#endif // CMK_LBDB_ON
diff --git a/src/ck-ldb/lbdb.h b/src/ck-ldb/lbdb.h
new file mode 100644 (file)
index 0000000..305d3d2
--- /dev/null
@@ -0,0 +1,149 @@
+#ifndef LBDBH_H
+#define LBDBH_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+  /*  User-defined object IDs will be 4 ints long */
+#define OBJ_ID_SZ 4
+
+typedef struct {
+  void *handle;
+} LDHandle;
+
+typedef struct {
+  int id;
+} LDOMid;
+
+typedef struct {
+  LDHandle ldb;
+  void *user_ptr;
+  LDOMid id;
+  int handle;
+} LDOMHandle;
+
+typedef struct {
+  int id[OBJ_ID_SZ];
+} LDObjid;
+
+typedef struct {
+  LDOMHandle omhandle;
+  void *user_ptr;
+  LDObjid id;
+  int handle;
+} LDObjHandle;
+
+typedef struct {
+  LDObjHandle handle;
+  LDObjid id;
+  LDOMHandle omHandle;
+  LDOMid omID;
+  double cpuTime;
+  double wallTime;
+} LDObjData;
+
+typedef struct {
+  LDObjid sender;
+  LDObjid receiver;
+  int nMessages;
+  int nBytes;
+} LDCommData;
+
+/*
+ * Requests to load balancer
+ */
+void LBBalance(void *param);
+void LBCollectStatsOn(void);
+void LBCollectStatsOff(void);
+
+/*
+ * Callbacks from database to object managers
+ */
+typedef void (*LDMigrateFn)(LDObjHandle handle, int dest);
+typedef void (*LDStatsFn)(LDOMHandle h, int state);
+typedef void (*LDQueryEstLoadFn)(LDOMHandle h);
+
+typedef struct {
+  LDMigrateFn migrate;
+  LDStatsFn setStats;
+  LDQueryEstLoadFn queryEstLoad;
+} LDCallbacks;
+
+/*
+ * Calls from object managers to load database
+ */
+LDHandle LDCreate(void);
+LDOMHandle LDRegisterOM(LDHandle lbdb, LDOMid userID, 
+                       void *userptr, LDCallbacks cb);
+void LDRegisteringObjects(LDOMHandle _h);
+void LDDoneRegisteringObjects(LDOMHandle _h);
+
+LDObjHandle LDRegisterObj(LDOMHandle h, LDObjid id, void *userptr,
+                         int migratable);
+void LDUnregisterObj(LDObjHandle h);
+
+void LDObjTime(LDObjHandle h, double walltime, double cputime);
+void LDObjectStart(LDObjHandle _h);
+void LDObjectStop(LDObjHandle _h);
+
+void LDMessage(LDObjHandle from, 
+              LDOMid toOM, LDObjid *toID, int bytes);
+
+void LDEstObjLoad(LDObjHandle h, double load);
+void LDNonMigratable(LDObjHandle h);
+void LDMigratable(LDObjHandle h);
+void LDDumpDatabase(LDHandle lbdb);
+
+/*
+ * Calls from load balancer to load database
+ */  
+typedef void (*LDMigratedFn)(void* data, LDObjHandle handle);
+void LDNotifyMigrated(LDHandle lbdb, LDMigratedFn fn, void* data);
+
+void LDCollectStatsOn(LDHandle lbdb);
+void LDCollectStatsOff(LDHandle lbdb);
+void LDQueryEstLoad(LDHandle bdb);
+
+int LDGetObjDataSz(LDHandle lbdb);
+void LDGetObjData(LDHandle lbdb, LDObjData *data);
+
+int LDGetCommDataSz(LDHandle lbdb);
+void LDGetCommData(LDHandle lbdb, LDCommData *data);
+
+void LDBackgroundLoad(LDHandle lbdb, double *walltime, double *cputime);
+void LDIdleTime(LDHandle lbdb, double *walltime, double *cputime);
+void LDTotalTime(LDHandle lbdb, double *walltime, double *cputime);
+
+void LDClearLoads(LDHandle lbdb);
+void LDMigrate(LDObjHandle h, int dest);
+void LDMigrated(LDObjHandle h);
+/*
+ * Local Barrier calls
+ */
+typedef void (*LDBarrierFn)(void *user_ptr);
+typedef void (*LDResumeFn)(void *user_ptr);
+
+typedef struct {
+  int serial;
+} LDBarrierClient;
+
+typedef struct {
+  int serial;
+} LDBarrierReceiver;
+
+LDBarrierClient LDAddLocalBarrierClient(LDHandle lbdb,LDResumeFn fn,
+                                       void* data);
+void LDRemoveLocalBarrierClient(LDHandle lbdb, LDBarrierClient h);
+LDBarrierReceiver LDAddLocalBarrierReceiver(LDHandle lbdb,LDBarrierFn fn,
+                                           void* data);
+void LDRemoveLocalBarrierReceiver(LDHandle lbdb,LDBarrierReceiver h);
+void LDAtLocalBarrier(LDHandle lbdb, LDBarrierClient h);
+void LDResumeClients(LDHandle lbdb);
+
+#ifdef __cplusplus
+}
+#endif /* _cplusplus */
+
+#endif /* LBDBH_H */
index 9cf69c0edbe10bb91b388c049aec22402d9627c2..3a009048875b1ec23a8ce431749b0aa88d81efb8 100644 (file)
@@ -59,7 +59,7 @@ SEQCHARMC=../bin/charmc -seq $(CHARMOPTS)
 #
 ###############################################################################
 
-ALLHEADERS=charm++.h ckstream.h charm.h cpthreads.h converse.h conv-trace.h conv-mach.h simplemsg.h sm.h trace.h pvmc.h pvm3.h sdag.h CDep.h CCounter.h CMsgBuffer.h CWhenTrigger.h TList.h idl.h ckarray.h tempo.h waitqd.h
+ALLHEADERS=charm++.h ckstream.h charm.h cpthreads.h converse.h conv-trace.h conv-mach.h simplemsg.h sm.h trace.h pvmc.h pvm3.h sdag.h CDep.h CCounter.h CMsgBuffer.h CWhenTrigger.h TList.h idl.h ckarray.h tempo.h waitqd.h LBDatabase.h lbdb.h LBDB.h LBOM.h LBObj.h CentralLB.h RandCentLB.h
 
 ALLINTERFACES=idl.ci
 
@@ -92,6 +92,7 @@ dirs+sources:
        ./gatherflat ../../src/Common/conv-ldb         .
        ./gatherflat ../../src/Common/ck-core          .
        ./gatherflat ../../src/Common/ck-perf          .
+       ./gatherflat ../../src/Common/ck-ldb           .
        ./gatherflat ../../src/Common/langs/simplemsg  .
        ./gatherflat ../../src/Common/langs/pvmc       .
        ./gatherflat ../../src/Common/langs/sdag/xlator       .
@@ -125,6 +126,9 @@ dirs+sources:
 CVHEADERS=converse.h conv-mach.h conv-mach.csh \
           ../include/CkFutures.decl.h CkFutures.def.h \
           ../include/CkArray.decl.h CkArray.def.h \
+          ../include/LBDatabase.decl.h LBDatabase.def.h \
+          ../include/CentralLB.decl.h CentralLB.def.h \
+          ../include/RandCentLB.decl.h RandCentLB.def.h \
           ../include/tempo.decl.h tempo.def.h \
           ../include/waitqd.decl.h waitqd.def.h
 
@@ -228,12 +232,16 @@ libldb-test.o: cldb.test.c $(CVHEADERS)
 ###############################################################################
 
 CKHEADERS=ck.h ckstream.h envelope.h init.h qd.h charm.h charm++.h trace.h \
-          ckfutures.h ckarray.h tempo.h waitqd.h $(CVHEADERS)
+          ckfutures.h ckarray.h tempo.h waitqd.h \
+         LBDatabase.h lbdb.h LBDB.h LBOM.h LBObj.h \
+         CentralLB.h RandCentLB.h \
+         $(CVHEADERS)
 
 CK_LIBS_CORE=libck.a
 
 LIBCK_CORE=init.o register.o qd.o ck.o main.o msgalloc.o ckfutures.o \
-           ckarray.o tempo.o waitqd.o
+           ckarray.o tempo.o waitqd.o \
+          LBDatabase.o lbdb.o LBDB.o LBObj.o CentralLB.o RandCentLB.o
 
 charmlibs: converse $(CK_LIBS_CORE)
        cd libs; make charmlibs OPTS='$(OPTS)'
@@ -252,6 +260,15 @@ libtrace-projections.a: $(LIBTRACE_PROJ)
 ../include/CkArray.decl.h : CkArray.decl.h
        /bin/cp CkArray.decl.h ../include
 
+../include/LBDatabase.decl.h : LBDatabase.decl.h
+       /bin/cp LBDatabase.decl.h ../include
+
+../include/CentralLB.decl.h : CentralLB.decl.h
+       /bin/cp CentralLB.decl.h ../include
+
+../include/RandCentLB.decl.h : RandCentLB.decl.h
+       /bin/cp RandCentLB.decl.h ../include
+
 ../include/CkFutures.decl.h : CkFutures.decl.h
        /bin/cp CkFutures.decl.h ../include
 
@@ -273,6 +290,15 @@ waitqd.decl.h waitqd.def.h : waitqd.ci charmxi
 CkArray.decl.h CkArray.def.h : ckarray.ci charmxi
        $(CHARMC) ckarray.ci
 
+LBDatabase.decl.h LBDatabase.def.h : LBDatabase.ci charmxi
+       $(CHARMC) LBDatabase.ci
+
+CentralLB.decl.h Central.def.h : CentralLB.ci charmxi
+       $(CHARMC) CentralLB.ci
+
+RandCentLB.decl.h RandCent.def.h : RandCentLB.ci charmxi
+       $(CHARMC) RandCentLB.ci
+
 init.o: init.C $(CKHEADERS)
        $(CHARMC) -o init.o init.C
 
@@ -294,6 +320,24 @@ waitqd.o: waitqd.C $(CKHEADERS)
 ckarray.o: ckarray.C $(CKHEADERS)
        $(CHARMC) -o ckarray.o ckarray.C
 
+lbdb.o: lbdb.C $(CKHEADERS)
+       $(CHARMC) -o lbdb.o lbdb.C
+
+LBDB.o:        LBDB.C $(CKHEADERS)
+       $(CHARMC) -o LBDB.o LBDB.C
+
+LBObj.o: LBObj.C $(CKHEADERS)
+       $(CHARMC) -o LBObj.o LBObj.C
+
+LBDatabase.o: LBDatabase.C $(CKHEADERS)
+       $(CHARMC) -o LBDatabase.o LBDatabase.C
+
+CentralLB.o: CentralLB.C $(CKHEADERS)
+       $(CHARMC) -o CentralLB.o CentralLB.C
+
+RandCentLB.o: RandCentLB.C $(CKHEADERS)
+       $(CHARMC) -o RandCentLB.o RandCentLB.C
+
 qd.o: qd.C $(CKHEADERS)
        $(CHARMC) -o qd.o qd.C