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
+
#!/bin/sh
-name="nlsop"
+name="nlsop_server nlsop_client nlsop_gui"
+main="nlsop"
#defaults
prefix=/usr
dfblib=""
dfbinc=""
+apidir=""
nodfb=0
echo $run_cmd
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
}
--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
[ "$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
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
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"
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 <value> \t # x cells (default %d)\n",X);
- printf("-y <value> \t # y cells (default %d)\n",Y);
- printf("-z <value> \t # z cells (default %d)\n",Z);
+ printf("-x <value> \t # x cells (default %d)\n",_X);
+ printf("-y <value> \t # y cells (default %d)\n",_Y);
+ printf("-z <value> \t # z cells (default %d)\n",_Z);
printf("-s <value> \t steps (default %d)\n",STEPS);
printf("-d <value> \t refresh display (default %d)\n",REFRESH);
printf("-r <value> \t amorphous influence range (default %d)\n",RANGE);
printf("-p <value> \t ballistic amorphization influence (default %f)\n",B_D);
printf("-F <value> \t carbon induced amorphization influence (default %f)\n",C_D);
printf("-D <value> \t diffusion rate from cryst to amorph cells (default %f)\n",DR_AC);
- printf("-c <value> \t diffusion rate in cryst cells (default %f)\n",DR_CC);
printf("-e <value> \t do diffusion every <value> steps (default %d)\n",DIFF_RATE);
puts("-g <file> <step> continue simulation from file and step (step > 0)!");
printf("-W <value> \t write every <value> steps to save file (default %d)\n",RESAVE);
}
}
}
- 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 */
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;
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;
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;
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);
#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
#include "network.h"
#include "event.h"
#include "display.h"
+#include "input.h"
#include "nlsop_general.h"
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;i<display->max_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<count;i++) {
+ network_receive_chan(net,0,(unsigned char *)&job,sizeof(t_job));
+ snprintf(string,MAX_CONTENT,
+ "channel %d %c => 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;
}
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;
}
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));
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));
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 */
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");
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);
/* 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);
}
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);