Commit d5427b31 authored by Edward Vigmond's avatar Edward Vigmond
Browse files

mesalyzer uses shared memory to avoid limit with semaphore values.

Bug fixes for axuiliary grids.
parent 6c86f583
......@@ -328,10 +328,6 @@ private:
int lines = get_num(infile);
// skip lines of frame
if (frame >= 50)
std::cerr << frame << " --- " << lines << std::endl;
for (int line = 0; line < lines; line++) {
get_line(infile);
}
......@@ -351,6 +347,11 @@ private:
*/
void seek(int frame)
{
if( frame>_max_tm ) {
cerr << "illegal frame specified!" << endl;
throw 3;
}
if( _vec_pts_pos.size() > 1 )
gzseek(_pts_in, _vec_pts_pos[frame], SEEK_SET);
else
......
......@@ -63,7 +63,6 @@ Frame :: write( int w, int h, string fname, int f0, int f1, int stride )
int numout=0;
for( int f=f0; f<=f1; f+=stride) {
printf("proc starting at %d outputting time %d\n", f0, f);
if( !_tbwm->set_time(f) )
break;
string file=fname;
......@@ -73,7 +72,6 @@ Frame :: write( int w, int h, string fname, int f0, int f1, int stride )
dump( w, h, file );
numout++;
}
printf("proc starting at %d returning %d\n", f0, numout);
return numout;
}
......
......@@ -44,7 +44,7 @@ meshalyzer: $(LIB_CH5) $(FLTK_SOURCES:.fl=.cc) $(OBJS) $(LIB_CH5)
fltk-config --post meshalyzer
mesalyzer: $(LIB_CH5) $(FLTK_SOURCES:.fl=.cc) $(OS_OBJS) $(LIB_CH5)
$(CXX) $(LDFLAGS) -o mesalyzer $(sort $(OS_OBJS)) -lOSMesa $(LIBS)
$(CXX) $(LDFLAGS) -o mesalyzer $(sort $(OS_OBJS)) -lOSMesa $(LIBS) -lrt
fltk-config --post mesalyzer
ifdef HDF5
......
......@@ -19,7 +19,11 @@
#include <ch5/ch5.h>
#endif
#ifndef OSMESA
#ifdef OSMESA
#include <sys/mman.h>
pid_t master;
#else
#include <GL/glut.h>
#endif
......@@ -41,6 +45,15 @@ sem_t *linkingProcSem; // global semaphore for process linking
*/
void do_cleanup( int sig, siginfo_t *si, void *v )
{
#ifndef OSMESA
stringstream nw_name("/nw_");
nw_name << getpid();
stringstream fini_name("/fini_");
fini_name << getpid();
sem_unlink( fini_name.str().c_str() );
sem_unlink( nw_name.str().c_str() );
#endif
exit(0);
}
......@@ -154,13 +167,19 @@ os_png_seq( string filename, int f0, int numf, TBmeshWin *tbwm, int size, int np
frame.write( size, size, filename, f0 );
} else {
#ifdef OSMESA
// create 2 semaphores needed for interprocess communication
stringstream nw_name("/nw_");
nw_name << getpid();
stringstream fini_name("/fini_");
fini_name << getpid();
// create 2 semaphores and shared memory needed for interprocess communication
stringstream nw_name("/nw");
master = getpid();
nw_name << master;
sem_t *nw_cnt = sem_open( nw_name.str().c_str(), O_CREAT, S_IRWXU, 1 );
stringstream fini_name("/fini");
fini_name << master;
sem_t *finished = sem_open( fini_name.str().c_str(), O_CREAT, S_IRWXU, 0 );
sem_t *nw_cnt = sem_open( nw_name.str().c_str(), O_CREAT, S_IRWXU, 0 );
stringstream cnt_name("/cnt");
cnt_name << master;
int shm = shm_open(cnt_name.str().c_str(), O_CREAT|O_RDWR, 0666);
ftruncate(shm, sizeof(int));
int *nwr = (int*)mmap(NULL, sizeof(int), PROT_READ|PROT_WRITE, MAP_SHARED, shm, 0 );
// fork since it is too difficult to copy tbwm with all of its dynamic allocations
for( int i=1; i<nproc;i++ ) {
......@@ -171,20 +190,21 @@ os_png_seq( string filename, int f0, int numf, TBmeshWin *tbwm, int size, int np
}
int nw = frame.write( size, size, filename, f0, f1, nproc );
for( int a=0; a<nw; a++ )
sem_post( nw_cnt );
sem_post( finished );
sem_wait( nw_cnt );
*nwr = *nwr + nw;
// wait for everyone to finish and count the number of frames written
sem_post( finished );
int nfin;
sem_getvalue( finished, &nfin );
if( nfin==nproc ) {
sem_getvalue( nw_cnt, &nw );
if( nw != numf )
cerr << "\nOnly " << nw << " of " << numf << " frames written\n" << endl;
if( *nwr != numf )
cerr << "\nOnly " << *nwr << " of " << numf << " frames written\n" << endl;
sem_unlink(nw_name.str().c_str() );
sem_unlink(fini_name.str().c_str() );
shm_unlink(cnt_name.str().c_str() );
}
sem_post( nw_cnt );
#else
int nw = frame.write( size, size, filename, f0, f1 );
......
......@@ -389,6 +389,7 @@ data. The grid may contain any of the elements forming the main grid
elements may change as a function of time.
If scalar data has already been read in, the number of time instances in
the auxiliary grid must either be one, or the same as the scalar data.
The points file may have only one time instance, which is then assumed constant over all time.
A vertex file is mandatory and has the extension ``.pts\_t''.
An element file is optional. If present, it has the same base name as the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment