From: hackbard Date: Thu, 4 Nov 2004 16:43:32 +0000 (+0000) Subject: untested finished nlsop* binaries - configure script needs to get adjusted. X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f7acbcafd89b6e3899b6bef51c7727a4c560221;p=physik%2Fnlsop.git untested finished nlsop* binaries - configure script needs to get adjusted. --- diff --git a/README b/README index f27ad08..5be6c4c 100644 --- a/README +++ b/README @@ -1,18 +1,52 @@ nlsop ------ +##### requirements: +------------- - directfb api (www.directfb.org) for visualization only + - /dev/urandom +- my own minimal api. you can get it via cvs: + + cvs -d:pserver:anonymous@hackdaworld.dyndns.org:/my-code co api + + you should downlaod it parllel to your nlsop dir, or use configure + option to specify the location instead. + install: +-------- ./configure && make -f Makefile && make -f Makefile install run: +---- + +(use '-h' to see the individual options of every binary) + +nlsop_server: + + install and run the binary on a stable, well connected host and enough + disk space for the nlsop save files. + +nlsop_client: -./nlsop -h + install and run it on a number of nodes you want to do the actual + calculation on. + +nlsop_gui: + + run it to connect to the server to add jobs or get a status information + of the current jobs and clients. + +nlsop: + + use this for visualizing/converting/researching the save files. + you may also use it for a non distributed calculation. + + +-- -- have fun, frank + diff --git a/configure b/configure index 3c5f599..303dde0 100755 --- a/configure +++ b/configure @@ -1,11 +1,13 @@ #!/bin/sh -name="nlsop" +name="nlsop_server nlsop_client nlsop_gui" +main="nlsop" #defaults prefix=/usr dfblib="" dfbinc="" +apidir="" nodfb=0 echo $run_cmd @@ -16,6 +18,7 @@ usage() { echo "--prefix=PREFIX specify install prefix" echo "--with-dfblib=DIR specify directfb lib dir" echo "--with-dfbinc=DIR specify directfb include dir" + echo "--with-api=DIR specify api dir" echo } @@ -26,9 +29,30 @@ while [ "$1" ]; do --with-dfblib) dfblib=`echo $1 | awk -F= '{ print $2 }'`; shift;; --with-dfbinc) dfbinc=`echo $1 | awk -F= '{ print $2 }'`; shift;; --without-dfb) nodfb=1; shift ;; + --with-api) apidir=`echo $1 | awk -F= '{ print $2 }'`; shift;; esac done +echo "checking for api stuff ..." +api_dir="0" +if [ -z "$apidir" ]; then + for i in ../api ../../api; do + if [ -f $i/CHANGELOG ]; then + api_dir=$i + fi + done +else + if [ -f $apidir/CHANGELOG ]; then + api_dir=$apidir + fi +fi +if [ "$api_dir" = "0" ]; then + echo "api files not found ..." + echo "WARNING: your build will fail." + echo "please get the api files first (see README file)." + api_dir="./" +fi + echo "checking for dfb stuff ..." dfb_inc_dir="0" if [ -z "$dfbinc" ]; then @@ -65,10 +89,13 @@ fi [ "$nodfb" = "0" ] && echo "directfb installation looks good :)" +GENLIBS="-lm -lncurses" +GENAPI="network.o event.o list.o display.o input.o" + echo "creating Makefile" cat > Makefile << EOF -# $name Makefile, created `date` +# $main Makefile, created `date` INCLUDEDIR = /usr/include EOF @@ -77,18 +104,18 @@ if [ "$nodfb" = "0" ]; then cat >> Makefile << EOF CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"$prefix/share/$name/decker.ttf\" -O3 -Wall -I$dfb_inc_dir -LIBS = -L$dfb_lib_dir -ldirectfb +LIBS = -L$dfb_lib_dir -ldirectfb $GENLIBS -OBJS = random.o dfbapi.o +OBJS = random.o dfbapi.o $GENAPI EOF else cat >> Makefile << EOF CFLAGS = -DDEBUG -DNODFB -O3 -Wall -LIBS = -lm +LIBS = -lm -lncurses -OBJS = random.o +OBJS = random.o $GENAPI EOF fi @@ -96,23 +123,45 @@ fi cat >> Makefile << EOF OBJS2 = $name -$name: \$(OBJS) - \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) \$(LIBS) ${name}.c +links: +EOF + +for i in $GENAPI; do + foo="`echo $i | sed 's/\.o//g'`" + cat >> Makefile << EOF + ln -sf $api_dir/$foo/${foo}.{c,h} . +EOF +done -all: $name +for i in $name; do +cat >> Makefile << EOF + +$i: links \$(OBJS) + \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) \$(LIBS) ${i}.c + +EOF +done + +cat >> Makefile << EOF +nlsop: links $name + \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) \$(LIBS) nlsop.c + +EOF + +cat >> Makefile << EOF +all: $main clean: - rm \$(OBJS) \$(OBJS2) + rm -f \$(OBJS) \$(OBJS2) remake: clean all install: mkdir -p $prefix/bin cp $name $prefix/bin - chmod 755 $prefix/bin/$name - mkdir -p $prefix/share/$name - cp decker.ttf $prefix/share/$name - chmod 644 $prefix/share/$name/decker.ttf + mkdir -p $prefix/share/$main + cp decker.ttf $prefix/share/$main + chmod 644 $prefix/share/$main/decker.ttf EOF echo "done" diff --git a/nlsop.c b/nlsop.c index fc34c8a..578a1de 100644 --- a/nlsop.c +++ b/nlsop.c @@ -55,9 +55,9 @@ int usage(void) puts("-n \t\t no user interaction"); puts("-Z \t\t cryst -> amorph c diffusion in z direction"); puts("-i \t\t no cryst to cryst diffusion"); - printf("-x \t # x cells (default %d)\n",X); - printf("-y \t # y cells (default %d)\n",Y); - printf("-z \t # z cells (default %d)\n",Z); + printf("-x \t # x cells (default %d)\n",_X); + printf("-y \t # y cells (default %d)\n",_Y); + printf("-z \t # z cells (default %d)\n",_Z); printf("-s \t steps (default %d)\n",STEPS); printf("-d \t refresh display (default %d)\n",REFRESH); printf("-r \t amorphous influence range (default %d)\n",RANGE); @@ -65,7 +65,6 @@ int usage(void) printf("-p \t ballistic amorphization influence (default %f)\n",B_D); printf("-F \t carbon induced amorphization influence (default %f)\n",C_D); printf("-D \t diffusion rate from cryst to amorph cells (default %f)\n",DR_AC); - printf("-c \t diffusion rate in cryst cells (default %f)\n",DR_CC); printf("-e \t do diffusion every steps (default %d)\n",DIFF_RATE); puts("-g continue simulation from file and step (step > 0)!"); printf("-W \t write every steps to save file (default %d)\n",RESAVE); @@ -204,74 +203,30 @@ int distrib_c(d3_lattice *d3_l,info *my_info,int step,u32 rj_m,u32 *rj_g) } } } - if(my_info->z_diff) + /* z diff */ + if(k!=0) { - if(k!=0) + off=i+j*d3_l->max_x+(k-1)*d3_l->max_x*d3_l->max_y; + carry=0; + if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); + if(carry!=0) { - off=i+j*d3_l->max_x+(k-1)*d3_l->max_x*d3_l->max_y; - carry=0; - if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); - if(carry!=0) - { - *(d3_l->extra+off)-=carry; - *(d3_l->extra+offset)+=carry; - } - } - if(k!=d3_l->max_z-1) - { - off=i+j*d3_l->max_x+(k+1)*d3_l->max_x*d3_l->max_y; - carry=0; - if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); - if(carry!=0) - { - *(d3_l->extra+off)-=carry; - *(d3_l->extra+offset)+=carry; - } - } - } - } else - /* case not amorph: cryst <-> cryst diffusion */ - if(my_info->c_diff) { - /* if there is c diff, no diff in z-direction */ - { - for(c=-1;c<=1;c++) - { - if(c!=0) - { - off=i+((j+c+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; - carry=0; - if(!(*(d3_l->status+off)&AMORPH)) - { - carry=(int)(my_info->dr_cc*(*(d3_l->extra+off)-*(d3_l->extra+offset))/2); - if(carry!=0) - { - *(d3_l->extra+offset)+=carry; - *(d3_l->extra+off)-=carry; - } - } + *(d3_l->extra+off)-=carry; + *(d3_l->extra+offset)+=carry; } } - for(c=-1;c<=1;c++) + if(k!=d3_l->max_z-1) { - if(c!=0) + off=i+j*d3_l->max_x+(k+1)*d3_l->max_x*d3_l->max_y; + carry=0; + if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); + if(carry!=0) { - off=((i+c+d3_l->max_x)%d3_l->max_x)+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; - carry=0; - if(!(*(d3_l->status+off)&AMORPH)) - { - carry=(int)(my_info->dr_cc*(*(d3_l->extra+off)-*(d3_l->extra+offset))/2); - if(carry!=0) - { - *(d3_l->extra+offset)+=carry; - *(d3_l->extra+off)-=carry; - } - } + *(d3_l->extra+off)-=carry; + *(d3_l->extra+offset)+=carry; } } } - /* end test */ - } - /* */ } /* for z */ } /* for y */ } /* for x */ @@ -1159,21 +1114,18 @@ int main(int argc,char **argv) u32 ne_max,ip_max; u32 nel_z; - d3_l.max_x=X; - d3_l.max_y=Y; - d3_l.max_z=Z; + d3_l.max_x=_X; + d3_l.max_y=_Y; + d3_l.max_z=_Z; my_info.steps=STEPS; my_info.range=RANGE; refresh=REFRESH; resave=RESAVE; - my_info.z_diff=0; - my_info.c_diff=1; my_info.s=S_D; my_info.b=B_D; my_info.c=C_D; my_info.cc=CC; my_info.dr_ac=DR_AC; - my_info.dr_cc=DR_CC; my_info.diff_rate=DIFF_RATE; my_info.cpi=CPI; my_info.s_rate=S_RATE; @@ -1218,13 +1170,6 @@ int main(int argc,char **argv) case 'z': d3_l.max_z=atoi(argv[++i]); break; - case 'Z': - my_info.z_diff=1; - break; - case 'i': - my_info.c_diff=0; - my_info.dr_cc=0; - break; case 's': my_info.steps=atoi(argv[++i]); break; @@ -1254,9 +1199,6 @@ int main(int argc,char **argv) case 'D': my_info.dr_ac=atof(argv[++i]); break; - case 'c': - my_info.dr_cc=atof(argv[++i]); - break; case 'e': my_info.diff_rate=atoi(argv[++i]); break; @@ -1371,9 +1313,7 @@ int main(int argc,char **argv) sprintf(ballistic_txt,"ballistic term: %f",my_info.b); sprintf(carbon_txt,"carbon term: %f",my_info.c); sprintf(dr_ac_txt,"a/c diffusion rate: %f",my_info.dr_ac); - if(my_info.c_diff!=0) sprintf(dr_cc_txt,"c/c diffusion rate: %f",my_info.dr_cc); - else sprintf(dr_cc_txt,"c/c diffusion rate: none"); - sprintf(zdiff_txt,"diffusion in z direction: %c",my_info.z_diff?'y':'n'); + sprintf(zdiff_txt,"diffusion in z direction: yes"); sprintf(diff_txt,"diffusion every %d steps",my_info.diff_rate); strcpy(mode_txt,"view: a/c mode"); sprintf(hpi_txt,"hits per ion: %d",my_info.cpi); diff --git a/nlsop.h b/nlsop.h index d41f84c..d63a507 100644 --- a/nlsop.h +++ b/nlsop.h @@ -21,9 +21,9 @@ typedef struct __info #define AMORPH 1 -#define X 64 -#define Y 64 -#define Z 233 +#define _X 64 +#define _Y 64 +#define _Z 233 #define STEPS 158671500 #define RANGE 5 diff --git a/nlsop_gui.c b/nlsop_gui.c index 0c56147..477d264 100644 --- a/nlsop_gui.c +++ b/nlsop_gui.c @@ -47,6 +47,7 @@ #include "network.h" #include "event.h" #include "display.h" +#include "input.h" #include "nlsop_general.h" @@ -65,11 +66,70 @@ int usage(char *prog) int display_new_line(t_display *display,char *text) { + int x,y; + int ptr; + int i; + + unsigned char *tmp; + + x=display->max_x-1; + y=display->max_y-1; + + tmp=(unsigned char *)malloc(display->max_x); + memset(tmp,0x20,display->max_x); + + display_line(display,0,0,x,0,'#'); + display_string(display,1,y-y/2-17,"nlsop gui (C) 2004 Frank Zirkelbach",35); + display_line(display,0,2,x,2,'#'); + display_line(display,0,y-1,x,y-1,'#'); + display_string(display,0,y,"prompt: ",8); + display_string(display,8,y,tmp,x-8); + display_set_cursor(display,8,y); + + ptr=3*display->max_x; + for(i=0;imax_x-6;i++) { + memcpy(display->screen+ptr,display->screen+ptr+display->max_x, + display->max_x); + ptr+=display->max_x; + } + + display_draw(display); + return 1; } int send_and_wait_for_answer(t_net *net,t_display *display) { + int i,count; + t_job job; + char data; + char string[MAX_CONTENT]; + + data=GUI_INFO; + + /* request information */ + network_send_chan(net,0,&data,sizeof(unsigned char)); + + /* receive information */ + network_receive_chan(net,0,&data,sizeof(unsigned char)); + if(data!=GUI_INFO) { + display_new_line(display,"no gui info answer, ignored"); + return -1; + } + + network_receive_chan(net,0,(unsigned char *)&count,sizeof(int)); + for(i=0;i b=%f c=%f s=%f | d: %d %f | %d", + job.channel,job.status&IN_WORK?'a':'q', + job.info.b,job.info.c,job.info.s, + job.info.diff_rate,job.info.dr_ac,job.progress); + display_new_line(display,string); + } + + display_new_line(display,"done"); + return 1; } @@ -80,9 +140,9 @@ int send_job(t_net *net,t_input *input,t_display *display) { info info; /* default values */ - x=X; - y=Y; - z=Z; + x=_X; + y=_Y; + z=_Z; info.cc=CC; info.steps=STEPS; info.range=RANGE; @@ -146,7 +206,7 @@ int send_job(t_net *net,t_input *input,t_display *display) { } command[0]=GUI_ADDJOB; - network_send_chan(net,0,data,1); + network_send_chan(net,0,command,1); network_send_chan(net,0,(unsigned char *)&x,sizeof(int)); network_send_chan(net,0,(unsigned char *)&y,sizeof(int)); @@ -163,8 +223,6 @@ int get_command(t_event *event,void *allineed) { t_display *display; t_input *input; - unsigned char data[64]; - net=(t_net *)allineed; display=(t_display *)(allineed+sizeof(t_net)); input=(t_input *)(allineed+sizeof(t_net)+sizeof(t_display)); @@ -174,7 +232,7 @@ int get_command(t_event *event,void *allineed) { send_and_wait_for_answer(net,display); break; case GUI_ADDJOB: - send_job(net,input,display) + send_job(net,input,display); break; case GUI_QUIT: /* stop everything */ @@ -182,7 +240,7 @@ int get_command(t_event *event,void *allineed) { network_shutdown(net); display_shutdown(display); input_shutdown(input); - event_shutdown(event); + event_stop(event); return 2; default: display_new_line(display,"unknown gui command"); @@ -255,7 +313,7 @@ int main(int argc,char **argv) allyouneed=malloc(sizeof(t_net)+sizeof(t_display)+sizeof(t_input)); memcpy(allyouneed,&net,sizeof(t_net)); memcpy(allyouneed+sizeof(t_net),&display,sizeof(t_display)); - memcpy(allyouneed+sizeof(t_net)+sizeof(t_display),sizeof(t_input)); + memcpy(allyouneed+sizeof(t_net)+sizeof(t_display),&input,sizeof(t_input)); /* input init */ input_init(&input,fd); @@ -272,6 +330,8 @@ int main(int argc,char **argv) /* user interaction */ event_math(0,&event,READ,ADD); + display_new_line(&display,"welcome to nlsop gui! :)"); + /* connect to server */ network_init(&net,fd); network_set_connection_info(&net,0,server_ip,port); @@ -281,10 +341,14 @@ int main(int argc,char **argv) } network_select(&net,0); + display_new_line(&display,"successfully connected to server"); + /* tell server: i am a client, i may work for you */ data=NLSOP_GUI; network_send(net.connection[0].fd,&data,1); + display_new_line(&display,"send data to server, waiting for input ..."); + /* wait for job */ event_start(&event,allyouneed,get_command,NULL);