00001 /* 00002 * This file is part of libc_utils. 00003 * 00004 * libc_utils is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * libc_utils is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with libc_utils; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00017 */ 00018 00019 /* 00020 * libc_utils is being developed at the Max-Planck-Institut fuer Astrophysik 00021 * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt 00022 * (DLR). 00023 */ 00024 00025 /* 00026 * Functionality for reading wall clock time 00027 * 00028 * Copyright (C) 2010, 2011 Max-Planck-Society 00029 * Author: Martin Reinecke 00030 */ 00031 00032 #if defined (_OPENMP) 00033 #include <omp.h> 00034 #elif defined (USE_MPI) 00035 #include "mpi.h" 00036 #else 00037 #include <sys/time.h> 00038 #include <stdlib.h> 00039 #endif 00040 00041 #include "walltime_c.h" 00042 00043 double wallTime(void) 00044 { 00045 #if defined (_OPENMP) 00046 return omp_get_wtime(); 00047 #elif defined (USE_MPI) 00048 return MPI_Wtime(); 00049 #else 00050 struct timeval t; 00051 gettimeofday(&t, NULL); 00052 return t.tv_sec + 1e-6*t.tv_usec; 00053 #endif 00054 }