Search This Blog

Tuesday, November 2, 2010

A simple timer (non-MPI)

struct timeval tempo1, tempo2;
long elapsed_utime; /* elapsed time in microseconds */
long elapsed_mtime; /* elapsed time in milliseconds */
long elapsed_seconds; /* diff between seconds counter */
long elapsed_useconds; /* diff between microseconds counter */

long total_usec = 0, total_msec = 0;

void StartSysTimer() {
gettimeofday(&tempo1, NULL);
}

void EndSysTimer() {
gettimeofday(&tempo2, NULL);

elapsed_seconds = tempo2.tv_sec - tempo1.tv_sec;
elapsed_useconds = tempo2.tv_usec - tempo1.tv_usec;

elapsed_utime = (elapsed_seconds) * 1000000 + elapsed_useconds;
elapsed_mtime = ((elapsed_seconds) * 1000 + elapsed_useconds/1000.0) + 0.5;

total_usec = total_usec + elapsed_utime;
total_msec = total_msec + elapsed_mtime;
}

void OutputTime() {

printf("Elapsed time = %ld microseconds\n", total_usec);
printf("Elapsed time = %ld milliseconds\n", total_msec);

}

Tuesday, September 21, 2010

Paper Abstract

- What is the problem?
- [Why is it important]?
- What is your solution?
- What is one going to find after reading your paper?
  • What's the system about?
  • Results

Sunday, August 1, 2010

Flaky VMWare Server WebUI 2.0.2 workaround

VMWare Server 2.0.2 WebUI bug... this kind of reminds me of my EMC days!! similar infrastructure, unbelievably similar UI and interestingly, similar bugs too :-D

Wednesday, June 9, 2010

Add a system independent sleep/clock to your program

Add a system independent sleep/clock to your program

http://www.faqs.org/faqs/unix-faq/faq/part4/section-6.html

extern int        select();

int
usleep( usec ) /* returns 0 if ok, else -1 */
long usec; /* delay in microseconds */
{
static struct /* `timeval' */
{
long tv_sec; /* seconds */
long tv_usec; /* microsecs */
} delay; /* _select() timeout */

delay.tv_sec = usec / 1000000L;
delay.tv_usec = usec % 1000000L;

return select( 0, (long *)0, (long *)0, (long *)0, &delay );
}

Monday, April 26, 2010

Cool ways of adding numbers in a text file in bash:

awk '{s+=$0} END {print s}' /tmp/file.txt

paste -sd+ /tmp/file.txt | bc

Source: http://unstableme.blogspot.com/2009/11/sum-of-numbers-in-file-unix.html

Saturday, April 24, 2010

Problem with Fortran + C code compilation:

undefined reference to `iargc_'
undefined reference to `getarg_'


Solution: use '_gfortran_iargc()' and '_gfortran_getarg_i4()' instead of 'iargc_()' and 'getargc_()'. This is specific to the situation where you link C with Fortran.
On the cluster, these are defined in /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgfortran.a.

http://osdir.com/ml/gcc.fortran/2005-02/msg00297.html
http://old.nabble.com/getarg-and-iargc-in-gcc-4.0.2-td1803996.html

Other links on Fortran + C compilation:

http://www.fnal.gov/docs/UNIX/unix_a.../uatf-107.html
http://astro.berkeley.edu/~wright/f2c.html
http://www.yolinux.com/TUTORIALS/Lin...rtranAndC.html