diff --git a/src/cutils_bgl.c b/src/cutils_bgl.c deleted file mode 100644 index a9a4169..0000000 --- a/src/cutils_bgl.c +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @file cutils_bgl.c - * - * @brief Utilities C functions. - * - * @copyright - * Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) - * SPC (Swiss Plasma Center) - * - * futils is free software: you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version. - * - * futils is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * @authors - * (in alphabetical order) - * @author Stephan Brunner - * @author Ben McMillan - * @author Trach-Minh Tran - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -static _BGP_Personality_t mybgp; - -/* returns memory per core in MBytes */ -unsigned bg_coreMB() { - unsigned procMB, coreMB; - Kernel_GetPersonality(&mybgp, sizeof(_BGP_Personality_t)); - procMB = BGP_Personality_DDRSizeMB(&mybgp); - coreMB = procMB/Kernel_ProcessCount(); - return coreMB; -} - -/* return maximum memory usage of process in kBytes */ -unsigned bg_usedKB() { - struct rusage usage; - if (getrusage(RUSAGE_SELF, &usage) != 0) - return 0; - return usage.ru_maxrss; -} - -double mem_per_core(void) -{ - // Return current memory usage in MB on BGP. - - return ((double)bg_coreMB()); -} - -double mem(void) -{ - - //* return ((double)sbrk(0)/1024.0/1024.0); on BGP - - return ((double)bg_usedKB()/1024.0); -} - -double second(void) -{ - // Return elapsed wall time in s. - - struct timeval tp; - struct timezone tzp; - int i; - i = gettimeofday(&tp,&tzp); - return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 ); -} - -double seconds(void) -{ - // Return elapsed wall time in s. - - struct timeval tp; - struct timezone tzp; - int i; - i = gettimeofday(&tp,&tzp); - return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 ); -} - -int fsize(const char *file, unsigned int l) -{ - // Return size of file in bytes - - struct stat buf; - stat( file, &buf); - return (int)buf.st_size; -} - -void ftos(const char *file, int *s, char *buf) -{ - // Put the content of file to a string - - int fd, n; - fd = open(file, O_RDONLY); - n = read(fd, buf, (size_t)*s); - close(fd); -} - -void stof(const char *file, int *s, char *buf) -{ - // Write string to file - - int fd, n; - fd = creat(file, 0644); - n = write(fd, buf, (size_t)*s); - close(fd); -} - -void stostdout(int *s, char *buf) -{ - // Write string to stdout - - int n; - n = write(1, buf, (size_t)*s); -} - -// Read in 1kb chunks in copy_file -#define CHSIZE 1024 - -void copy_file(char *infile, int *lengthin, char *outfile, int *lengthout) { - - // Copies a file from one location to another using fread, fwrite. - - char buf[CHSIZE]; - int err, count=CHSIZE; - - memcpy(buf,infile,CHSIZE*sizeof(char)); - buf[*lengthin . - * - * @authors - * (in alphabetical order) - * @author Sébastien Jolliet - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include -//#include -//#include -//#include - -//static _BGP_Personality_t mybgp; - -/* returns memory per core in MBytes */ -//unsigned bg_coreMB() { -// unsigned procMB, coreMB; -// Kernel_GetPersonality(&mybgp, sizeof(_BGP_Personality_t)); -// procMB = BGP_Personality_DDRSizeMB(&mybgp); -// coreMB = procMB/Kernel_ProcessCount(); -// return coreMB; -//} - -/* return maximum memory usage of process in kBytes */ -//unsigned bg_usedKB() { -// struct rusage usage; -// if (getrusage(RUSAGE_SELF, &usage) != ) -// return 0; -// return usage.ru_maxrss; -//} - -double mem_per_core(void) -{ - // Return current memory usage in MB on BGP. - - return (0); -} - -double mem(void) -{ - - //* return ((double)sbrk(0)/1024.0/1024.0); on BGP - - return (0); -} - -double second(void) -{ - // Return elapsed wall time in s. - - struct timeval tp; - struct timezone tzp; - int i; - i = gettimeofday(&tp,&tzp); - return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 ); -} - -double seconds(void) -{ - // Return elapsed wall time in s. - - struct timeval tp; - struct timezone tzp; - int i; - i = gettimeofday(&tp,&tzp); - return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 ); -} - -int fsize(const char *file, unsigned int l) -{ - // Return size of file in bytes - - struct stat buf; - stat( file, &buf); - return (int)buf.st_size; -} - -void ftos(const char *file, int *s, char *buf) -{ - // Put the content of file to a string - - int fd, n; - fd = open(file, O_RDONLY); - n = read(fd, buf, (size_t)*s); - close(fd); -} - -void stof(const char *file, int *s, char *buf) -{ - // Write string to file - - int fd, n; - fd = creat(file, 0644); - n = write(fd, buf, (size_t)*s); - close(fd); -} - -void stostdout(int *s, char *buf) -{ - // Write string to stdout - - int n; - n = write(1, buf, (size_t)*s); -} - -// Read in 1kb chunks in copy_file -#define CHSIZE 1024 - -void copy_file(char *infile, int *lengthin, char *outfile, int *lengthout) { - - // Copies a file from one location to another using fread, fwrite. - - char buf[CHSIZE]; - int err, count=CHSIZE; - - memcpy(buf,infile,CHSIZE*sizeof(char)); - buf[*lengthin