1
0
Fork 0

Refinements to the parallelization tools

This commit is contained in:
curt 1999-05-22 01:15:32 +00:00
parent 6f72fa77ad
commit 4108680ce0
6 changed files with 103 additions and 25 deletions

View file

@ -2,7 +2,7 @@ noinst_LIBRARIES = libArray.a
libArray_a_SOURCES = array.cxx array.hxx libArray_a_SOURCES = array.cxx array.hxx
bin_PROGRAMS = testarray noinst_PROGRAMS = testarray
testarray_SOURCES = testarray.cxx testarray_SOURCES = testarray.cxx

View file

@ -2,7 +2,7 @@ noinst_LIBRARIES = libClipper.a
libClipper_a_SOURCES = clipper.cxx clipper.hxx libClipper_a_SOURCES = clipper.cxx clipper.hxx
bin_PROGRAMS = testclipper noinst_PROGRAMS = testclipper
testclipper_SOURCES = testclipper.cxx testclipper_SOURCES = testclipper.cxx

View file

@ -1,8 +1,11 @@
bin_PROGRAMS = construct master bin_PROGRAMS = fgfs-construct fgfs-master
construct_SOURCES = construct.cxx construct.hxx main.cxx construct_types.hxx fgfs_construct_SOURCES = \
construct_types.hxx \
construct.cxx construct.hxx \
main.cxx
construct_LDADD = \ fgfs_construct_LDADD = \
$(top_builddir)/Tools/Construct/Array/libArray.a \ $(top_builddir)/Tools/Construct/Array/libArray.a \
$(top_builddir)/Tools/Construct/Clipper/libClipper.a \ $(top_builddir)/Tools/Construct/Clipper/libClipper.a \
$(top_builddir)/Tools/Construct/GenOutput/libGenOutput.a \ $(top_builddir)/Tools/Construct/GenOutput/libGenOutput.a \
@ -18,9 +21,9 @@ construct_LDADD = \
$(top_builddir)/Lib/zlib/libz.a \ $(top_builddir)/Lib/zlib/libz.a \
-lgpc -lgfc -lgpc -lgfc
master_SOURCES = master.cxx fgfs_master_SOURCES = master.cxx
master_LDADD = \ fgfs_master_LDADD = \
$(top_builddir)/Lib/Bucket/libBucket.a \ $(top_builddir)/Lib/Bucket/libBucket.a \
$(top_builddir)/Lib/Misc/libMisc.a $(top_builddir)/Lib/Misc/libMisc.a

View file

@ -1,14 +1,14 @@
bin_PROGRAMS = server client bin_PROGRAMS = fgfs-tools-server fgfs-tools-client
server_SOURCES = server.cxx fgfs_tools_server_SOURCES = server.cxx
server_LDADD = \ fgfs_tools_server_LDADD = \
$(top_builddir)/Lib/Bucket/libBucket.a \ $(top_builddir)/Lib/Bucket/libBucket.a \
$(top_builddir)/Lib/Misc/libMisc.a $(top_builddir)/Lib/Misc/libMisc.a
client_SOURCES = client.cxx fgfs_tools_client_SOURCES = client.cxx
client_LDADD = \ fgfs_tools_client_LDADD = \
$(top_builddir)/Lib/Bucket/libBucket.a \ $(top_builddir)/Lib/Bucket/libBucket.a \
$(top_builddir)/Lib/Misc/libMisc.a $(top_builddir)/Lib/Misc/libMisc.a

View file

@ -9,6 +9,8 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <utmp.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> // atoi() #include <stdlib.h> // atoi()
#include <string.h> // bcopy() #include <string.h> // bcopy()
@ -20,6 +22,47 @@
#define MAXBUF 1024 #define MAXBUF 1024
#define BUSY_WAIT_TIME 30
string work_base = "";
string output_base = "";
// check if it is ok to run
void check_master_switch() {
string file = work_base + ".status/MASTER_ON";
FILE *fp = fopen( file.c_str(), "r" );
if ( fp == NULL ) {
cout << "MASTER_ON file not found ... exiting." << endl;
exit(0);
}
fclose( fp );
}
// check if the host system is free of interactive users
int system_free() {
struct utmp *uptr;
setutent();
while ( (uptr = getutent()) != NULL ) {
// cout << "NULL = " << NULL << " uptr = " << uptr << endl;
// cout << "user = ut_user = " << uptr->ut_user << endl;
// cout << "user = ut_type = " << uptr->ut_type << endl;
if (uptr->ut_type == USER_PROCESS) {
// found someone
endutent();
return 0;
}
}
endutent();
return 1;
}
int make_socket (char *host, unsigned short int port) { int make_socket (char *host, unsigned short int port) {
@ -64,8 +107,11 @@ long int get_next_task( const string& host, int port, long int last_tile ) {
fd_set ready; fd_set ready;
char message[256]; char message[256];
while ( (sock = make_socket( host.c_str(), port )) < 0 ) {
// loop till we get a socket connection // loop till we get a socket connection
while ( (sock = make_socket( host.c_str(), port )) < 0 ) {
// check if the master switch is on
check_master_switch();
sleep(1); sleep(1);
} }
@ -108,8 +154,7 @@ long int get_next_task( const string& host, int port, long int last_tile ) {
// build the specified tile, return true if contruction completed // build the specified tile, return true if contruction completed
// successfully // successfully
bool construct_tile( const string& work_base, const string& output_base, bool construct_tile( const FGBucket& b, const string& result_file ) {
const FGBucket& b, const string& result_file ) {
double angle = 10.0; double angle = 10.0;
bool still_trying = true; bool still_trying = true;
@ -117,7 +162,7 @@ bool construct_tile( const string& work_base, const string& output_base,
still_trying = false; still_trying = false;
char angle_str[256]; char angle_str[256];
sprintf(angle_str, "%.0f", angle); sprintf(angle_str, "%.0f", angle);
string command = "../Main/construct "; string command = "fgfs-construct ";
command += angle_str; command += angle_str;
command += " " + work_base + " " + output_base + " " command += " " + work_base + " " + output_base + " "
+ b.gen_index_str() + " > " + result_file + " 2>&1"; + b.gen_index_str() + " > " + result_file + " 2>&1";
@ -130,7 +175,7 @@ bool construct_tile( const string& work_base, const string& output_base,
while ( fgets( line, 256, fp ) != NULL ) { while ( fgets( line, 256, fp ) != NULL ) {
string line_str = line; string line_str = line;
line_str = line_str.substr(0, line_str.length() - 1); line_str = line_str.substr(0, line_str.length() - 1);
cout << line_str << endl; // cout << line_str << endl;
if ( line_str == "[Finished successfully]" ) { if ( line_str == "[Finished successfully]" ) {
fclose(fp); fclose(fp);
return true; return true;
@ -163,20 +208,28 @@ bool construct_tile( const string& work_base, const string& output_base,
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
long int tile, last_tile; long int tile, last_tile;
bool rude = false;
bool result; bool result;
// Check usage // Check usage
if ( argc < 5 ) { if ( argc < 5 ) {
printf("Usage: %s remote_machine port work_base output_base\n", printf("Usage: %s remote_machine port work_base output_base [ -r ]\n",
argv[0]); argv[0]);
exit(1); exit(1);
} }
string host = argv[1]; string host = argv[1];
int port = atoi( argv[2] ); int port = atoi( argv[2] );
string work_base = argv[3]; work_base = argv[3];
string output_base = argv[4]; output_base = argv[4];
if ( argc == 6 ) {
string option = argv[5];
if ( option == "-r" ) {
cout << "Running in RUDE mode!" << endl;
rude = true;
}
}
// get hostname and pid // get hostname and pid
char hostname[MAXBUF]; char hostname[MAXBUF];
gethostname( hostname, MAXBUF ); gethostname( hostname, MAXBUF );
@ -188,13 +241,28 @@ main(int argc, char *argv[]) {
last_tile = 0; last_tile = 0;
// check if the master switch is on
check_master_switch();
while ( (tile = get_next_task( host, port, last_tile )) >= 0 ) { while ( (tile = get_next_task( host, port, last_tile )) >= 0 ) {
result = construct_tile( work_base, output_base, result = construct_tile( FGBucket(tile), result_file );
FGBucket(tile), result_file );
if ( result ) { if ( result ) {
last_tile = tile; last_tile = tile;
} else { } else {
last_tile = -tile; last_tile = -tile;
} }
// check if the master switch is on
check_master_switch();
// niceness policy: This whole process should run niced. But
// additionally, if there is interactive use, we will sleep
// for 60 seconds between each tile to stagger out the load
// and impose less of an impact on the machine.
if ( !system_free() && !rude) {
cout << "System has interactive use, sleeping for "
<< BUSY_WAIT_TIME << " seconds..." << endl;
sleep( BUSY_WAIT_TIME );
}
} }
} }

View file

@ -26,7 +26,7 @@ static double lat = 0.0;
static double lon = 0.0; static double lon = 0.0;
static double dy = 0.0; static double dy = 0.0;
static int pass = 0; static int pass = 0;
static bool first_time = false;
int make_socket (unsigned short int* port) { int make_socket (unsigned short int* port) {
int sock; int sock;
@ -134,7 +134,12 @@ long int get_next_tile( const string& work_base )
// reset lat // reset lat
// lat = -89.0 + (shift_up*dy) - (dy*0.5); // lat = -89.0 + (shift_up*dy) - (dy*0.5);
// lat = 27.0 + (0*dy) + (dy*0.5); // lat = 27.0 + (0*dy) + (dy*0.5);
if ( first_time ) {
first_time = false;
lat = 54.0 + (dy*0.5);
} else {
lat = 15.0 + (shift_up*dy) + (dy*0.5); lat = 15.0 + (shift_up*dy) + (dy*0.5);
}
// reset lon // reset lon
FGBucket tmp( 0.0, lat ); FGBucket tmp( 0.0, lat );
@ -164,7 +169,6 @@ long int get_next_tile( const string& work_base )
} }
b = FGBucket( lon, lat ); b = FGBucket( lon, lat );
cout << "Bucket = " << b << " (" << pass << ")" << endl;
// increment to next tile // increment to next tile
FGBucket tmp( 0.0, lat ); FGBucket tmp( 0.0, lat );
@ -264,6 +268,9 @@ int main( int argc, char **argv ) {
next_tile = get_next_tile( work_base ); next_tile = get_next_tile( work_base );
} }
cout << "Bucket = " << FGBucket(next_tile)
<< " (" << pass << ")" << endl;
log_pending_tile( status_dir, next_tile ); log_pending_tile( status_dir, next_tile );
// cout << "next tile = " << next_tile << endl;; // cout << "next tile = " << next_tile << endl;;