aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2022-04-29 16:13:10 +0200
committerThomas White <taw@physics.org>2022-05-03 12:45:34 +0200
commitcdb51dbec109ccde45c8a4ceb29ea925d01e2920 (patch)
tree050c15bce49627dba7bb2a04e1df43ba72a6f002 /libcrystfel
parent9ddf2feeffd29bf6bff376413832cd35e5cb3594 (diff)
Strip out time-accounts
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/CMakeLists.txt1
-rw-r--r--libcrystfel/meson.build4
-rw-r--r--libcrystfel/src/image.c40
-rw-r--r--libcrystfel/src/image.h10
-rw-r--r--libcrystfel/src/time-accounts.c265
-rw-r--r--libcrystfel/src/time-accounts.h75
6 files changed, 11 insertions, 384 deletions
diff --git a/libcrystfel/CMakeLists.txt b/libcrystfel/CMakeLists.txt
index 9aca17d8..69668a8c 100644
--- a/libcrystfel/CMakeLists.txt
+++ b/libcrystfel/CMakeLists.txt
@@ -62,7 +62,6 @@ set(LIBCRYSTFEL_SOURCES
src/image-hdf5.c
src/fom.c
src/image-msgpack.c
- src/time-accounts.c
${BISON_symopp_OUTPUTS}
${FLEX_symopl_OUTPUTS}
src/indexers/dirax.c
diff --git a/libcrystfel/meson.build b/libcrystfel/meson.build
index 5f6a32e5..5b10ce14 100644
--- a/libcrystfel/meson.build
+++ b/libcrystfel/meson.build
@@ -121,7 +121,6 @@ libcrystfel_sources = ['src/image.c',
'src/colscale.c',
'src/detgeom.c',
'src/fom.c',
- 'src/time-accounts.c',
'src/image-cbf.c',
'src/image-hdf5.c',
'src/image-msgpack.c',
@@ -180,8 +179,7 @@ install_headers(['src/reflist.h',
'src/datatemplate.h',
'src/colscale.h',
'src/detgeom.h',
- 'src/fom.h',
- 'src/time-accounts.h'],
+ 'src/fom.h'],
subdir: 'crystfel')
# API documentation (Doxygen)
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 7b86588d..7ad8d428 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -42,7 +42,6 @@
#include "image-hdf5.h"
#include "image-cbf.h"
#include "image-msgpack.h"
-#include "time-accounts.h"
#include "datatemplate.h"
#include "datatemplate_priv.h"
@@ -1287,35 +1286,28 @@ struct image *image_create_for_simulation(const DataTemplate *dtempl)
static int do_image_read(struct image *image, const DataTemplate *dtempl,
- int no_image_data, int no_mask_data,
- TimeAccounts *taccs)
+ int no_image_data, int no_mask_data)
{
int i;
/* Load the image data */
- time_accounts_set(taccs, TACC_IMAGE_DATA);
if ( !no_image_data ) {
if ( image_read_image_data(image, dtempl) ) return 1;
} else {
if ( image_set_zero_data(image, dtempl) ) return 1;
}
- time_accounts_set(taccs, TACC_IMAGE_PARAMS);
if ( set_image_parameters(image, dtempl) ) {
ERROR("Failed to read image parameters\n");
return 1;
}
- time_accounts_set(taccs, TACC_CREATE_DETGEOM);
if ( create_detgeom(image, dtempl) ) {
ERROR("Failed to read geometry information\n");
return 1;
}
- time_accounts_set(taccs, TACC_CREATE_BADMAP);
if ( create_badmap(image, dtempl, no_mask_data) ) return 1;
- time_accounts_set(taccs, TACC_CREATE_SATMAP);
if ( create_satmap(image, dtempl) ) return 1;
- time_accounts_set(taccs, TACC_CACHE_HEADERS);
for ( i=0; i<dtempl->n_headers_to_copy; i++ ) {
read_header_to_cache(image, dtempl->headers_to_copy[i]);
}
@@ -1324,12 +1316,11 @@ static int do_image_read(struct image *image, const DataTemplate *dtempl,
}
-struct image *image_read_with_time_accounting(const DataTemplate *dtempl,
- const char *filename,
- const char *event,
- int no_image_data,
- int no_mask_data,
- TimeAccounts *taccs)
+struct image *image_read(const DataTemplate *dtempl,
+ const char *filename,
+ const char *event,
+ int no_image_data,
+ int no_mask_data)
{
struct image *image;
@@ -1355,7 +1346,7 @@ struct image *image_read_with_time_accounting(const DataTemplate *dtempl,
image->data_source_type = file_type(image->filename);
- if ( do_image_read(image, dtempl, no_image_data, no_mask_data, taccs) ) {
+ if ( do_image_read(image, dtempl, no_image_data, no_mask_data) ) {
image_free(image);
return NULL;
}
@@ -1364,26 +1355,13 @@ struct image *image_read_with_time_accounting(const DataTemplate *dtempl,
}
-struct image *image_read(const DataTemplate *dtempl,
- const char *filename,
- const char *event,
- int no_image_data,
- int no_mask_data)
-{
- return image_read_with_time_accounting(dtempl, filename, event,
- no_image_data, no_mask_data,
- NULL);
-}
-
-
struct image *image_read_data_block(const DataTemplate *dtempl,
void *data_block,
size_t data_block_size,
DataSourceType type,
int serial,
int no_image_data,
- int no_mask_data,
- TimeAccounts *taccs)
+ int no_mask_data)
{
struct image *image;
char tmp[64];
@@ -1407,7 +1385,7 @@ struct image *image_read_data_block(const DataTemplate *dtempl,
image->data_source_type = type;
- if ( do_image_read(image, dtempl, no_image_data, no_mask_data, taccs) ) {
+ if ( do_image_read(image, dtempl, no_image_data, no_mask_data) ) {
image_free(image);
ERROR("Failed to load image\n");
return NULL;
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 78fd01cd..3746e115 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -45,7 +45,6 @@ struct image;
#include "index.h"
#include "spectrum.h"
#include "datatemplate.h"
-#include "time-accounts.h"
/**
* \file image.h
@@ -221,12 +220,6 @@ extern struct image *image_read(const DataTemplate *dtempl,
const char *event,
int no_image_data,
int no_mask_data);
-extern struct image *image_read_with_time_accounting(const DataTemplate *dtempl,
- const char *filename,
- const char *event,
- int no_image_data,
- int no_mask_data,
- TimeAccounts *taccs);
extern struct image *image_create_for_simulation(const DataTemplate *dtempl);
extern struct image *image_read_data_block(const DataTemplate *dtempl,
@@ -235,8 +228,7 @@ extern struct image *image_read_data_block(const DataTemplate *dtempl,
DataSourceType type,
int serial,
int no_image_data,
- int no_mask_data,
- TimeAccounts *taccs);
+ int no_mask_data);
extern void image_free(struct image *image);
extern int image_read_header_float(struct image *image, const char *from,
diff --git a/libcrystfel/src/time-accounts.c b/libcrystfel/src/time-accounts.c
deleted file mode 100644
index df2ccbb2..00000000
--- a/libcrystfel/src/time-accounts.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * time-accounts.c
- *
- * Simple profiling according to wall clock time
- *
- * Copyright © 2016-2021 Deutsches Elektronen-Synchrotron DESY,
- * a research centre of the Helmholtz Association.
- *
- * Authors:
- * 2016-2018 Thomas White <taw@physics.org>
- *
- * This file is part of CrystFEL.
- *
- * CrystFEL is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * CrystFEL 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 General Public License
- * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <libcrystfel-config.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <assert.h>
-
-#include "time-accounts.h"
-
-#define MAX_ACCOUNTS 256
-
-#ifndef CLOCK_MONOTONIC_RAW
-#define CLOCK_MONOTONIC_RAW (CLOCK_MONOTONIC)
-#endif
-
-struct _timeaccounts
-{
- enum timeaccount accs[MAX_ACCOUNTS];
- time_t sec[MAX_ACCOUNTS];
- long nsec[MAX_ACCOUNTS];
- int n_accs;
- enum timeaccount cur_acc;
- time_t cur_sec;
- long cur_nsec;
-};
-
-
-TimeAccounts *time_accounts_init()
-{
- TimeAccounts *accs = malloc(sizeof(struct _timeaccounts));
- if ( accs == NULL ) return NULL;
-
- accs->n_accs = 0;
- accs->cur_acc = TACC_NOTHING;
-
-#ifndef HAVE_CLOCK_GETTIME
- printf("Profiling disabled because clock_gettime is not available\n");
-#endif
-
- return accs;
-}
-
-
-void time_accounts_free(TimeAccounts *accs)
-{
- free(accs);
-}
-
-
-static int find_account(TimeAccounts *accs, enum timeaccount acc)
-{
- int i;
-
- for ( i=0; i<accs->n_accs; i++ ) {
- if ( accs->accs[i] == acc ) return i;
- }
-
- if ( i == MAX_ACCOUNTS ) {
- static int warned_toomany = 0;
- if ( !warned_toomany ) printf("Too many time accounts used!\n");
- warned_toomany = 1;
- return MAX_ACCOUNTS;
- }
-
- /* This is the first time the account is used */
- accs->accs[i] = acc;
- accs->sec[i] = 0;
- accs->nsec[i] = 0;
- accs->n_accs++;
- return i;
-}
-
-
-void time_accounts_reset(TimeAccounts *accs)
-{
- accs->n_accs = 0;
- accs->cur_acc = TACC_NOTHING;
-}
-
-
-#ifdef HAVE_CLOCK_GETTIME
-
-void time_accounts_set(TimeAccounts *accs, enum timeaccount new_acc)
-{
- struct timespec tp;
-
- if ( accs == NULL ) return;
-
- clock_gettime(CLOCK_MONOTONIC_RAW, &tp);
-
- /* Record time used on the previous account */
- if ( accs->cur_acc != TACC_NOTHING ) {
- int i = find_account(accs, accs->cur_acc);
- if ( i == MAX_ACCOUNTS ) {
- printf("Too many time accounts!\n");
- } else {
-
- time_t sec = tp.tv_sec - accs->cur_sec;
- long nsec = tp.tv_nsec - accs->cur_nsec;
-
- if ( nsec < 0 ) {
- sec -= 1;
- nsec += 1000000000;
- }
- accs->sec[i] += sec;
- accs->nsec[i] += nsec;
-
- while ( accs->nsec[i] > 1000000000 ) {
- accs->sec[i] += 1;
- accs->nsec[i] -= 1000000000;
- }
-
- }
- }
-
- accs->cur_acc = new_acc;
- accs->cur_sec = tp.tv_sec;
- accs->cur_nsec = tp.tv_nsec;
-}
-
-#else
-
-void time_accounts_set(TimeAccounts *accs, enum timeaccount new_acc)
-{
- if ( accs == NULL ) return;
-
- /* Record time used on the previous account */
- if ( accs->cur_acc != TACC_NOTHING ) {
- int i = find_account(accs, accs->cur_acc);
- if ( i == MAX_ACCOUNTS ) {
- printf("Too many time accounts!\n");
- } else {
- /* Do nothing because we have no timer */
- }
- }
-
- accs->cur_acc = new_acc;
- accs->cur_sec = 0;
- accs->cur_nsec = 0;
-}
-
-#endif
-
-static const char *taccname(enum timeaccount acc)
-{
- switch ( acc ) {
- case TACC_NOTHING : return "Nothing";
- case TACC_SELECT : return "select()";
- case TACC_STREAMREAD : return "Stream read";
- case TACC_SIGNALS : return "Checking signals";
- case TACC_QUEUETOPUP : return "Topping up queue";
- case TACC_STATUS : return "Printing status";
- case TACC_ENDCHECK : return "Checking end";
- case TACC_WAKEUP : return "Waking up workers";
- case TACC_WAITPID : return "Waiting on workers";
- case TACC_WAITFILE : return "Waiting for image file";
- case TACC_IMAGE_DATA : return "Reading image data";
- case TACC_IMAGE_PARAMS : return "Reading image parameters";
- case TACC_CREATE_DETGEOM : return "Creating detgeom";
- case TACC_CREATE_BADMAP : return "Creating bad pixel map";
- case TACC_CREATE_SATMAP : return "Creating saturation map";
- case TACC_CACHE_HEADERS : return "Caching image headers";
- case TACC_FILTER : return "Image filters";
- case TACC_RESRANGE : return "Resolution range";
- case TACC_PEAKSEARCH : return "Peak search";
- case TACC_INDEXING : return "Indexing";
- case TACC_PREDPARAMS : return "Prediction parameters";
- case TACC_INTEGRATION : return "Integration";
- case TACC_TOTALS : return "Crystal totals";
- case TACC_WRITESTREAM : return "Writing stream";
- case TACC_CLEANUP : return "Image cleanup";
- case TACC_EVENTWAIT : return "Waiting for event";
- case TACC_FINALCLEANUP : return "Final cleanup";
- default : return "Unknown";
- }
-}
-
-
-static const char *taccname_short(enum timeaccount acc)
-{
- switch ( acc ) {
- case TACC_NOTHING : return "?????";
- case TACC_SELECT : return "selct";
- case TACC_STREAMREAD : return "sread";
- case TACC_SIGNALS : return "signs";
- case TACC_QUEUETOPUP : return "qfill";
- case TACC_STATUS : return "print";
- case TACC_ENDCHECK : return "endch";
- case TACC_WAKEUP : return "wakew";
- case TACC_WAITPID : return "waitw";
- case TACC_WAITFILE : return "wfile";
- case TACC_IMAGE_DATA : return "idata";
- case TACC_IMAGE_PARAMS : return "iprms";
- case TACC_CREATE_DETGEOM : return "dgeom";
- case TACC_CREATE_BADMAP : return "bdmap";
- case TACC_CREATE_SATMAP : return "stmap";
- case TACC_CACHE_HEADERS : return "headc";
- case TACC_FILTER : return "filtr";
- case TACC_RESRANGE : return "rrnge";
- case TACC_PEAKSEARCH : return "peaks";
- case TACC_INDEXING : return "index";
- case TACC_PREDPARAMS : return "predp";
- case TACC_INTEGRATION : return "integ";
- case TACC_TOTALS : return "ctotl";
- case TACC_WRITESTREAM : return "swrte";
- case TACC_CLEANUP : return "clean";
- case TACC_EVENTWAIT : return "wevnt";
- case TACC_FINALCLEANUP : return "final";
- default : return "unkwn";
- }
-}
-
-
-void time_accounts_print_short(TimeAccounts *accs)
-{
- int i;
- time_accounts_set(accs, accs->cur_acc);
- for ( i=0; i<accs->n_accs; i++ ) {
- printf("%s: %.3f ", taccname_short(accs->accs[i]),
- (double)accs->sec[i] + accs->nsec[i]/1e9);
- }
- printf("\n");
- fflush(stdout);
-}
-
-
-void time_accounts_print(TimeAccounts *accs)
-{
- int i;
- printf("Wall clock time budget:\n");
- printf("-----------------------\n");
- for ( i=0; i<accs->n_accs; i++ ) {
- printf("%25s: %10lli sec %10li nsec\n", taccname(accs->accs[i]),
- (long long)accs->sec[i], accs->nsec[i]);
- }
-}
diff --git a/libcrystfel/src/time-accounts.h b/libcrystfel/src/time-accounts.h
deleted file mode 100644
index 56b44fa6..00000000
--- a/libcrystfel/src/time-accounts.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * time-accounts.h
- *
- * Simple profiling according to wall clock time
- *
- * Copyright © 2016-2021 Deutsches Elektronen-Synchrotron DESY,
- * a research centre of the Helmholtz Association.
- *
- * Authors:
- * 2016-2018 Thomas White <taw@physics.org>
- *
- * This file is part of CrystFEL.
- *
- * CrystFEL is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * CrystFEL 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 General Public License
- * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef TIME_ACCOUNTS_H
-#define TIME_ACCOUNTS_H
-
-enum timeaccount
-{
- TACC_NOTHING,
- TACC_STREAMREAD,
- TACC_SELECT,
- TACC_SIGNALS,
- TACC_QUEUETOPUP,
- TACC_STATUS,
- TACC_ENDCHECK,
- TACC_WAKEUP,
- TACC_WAITPID,
- TACC_WAITFILE,
- TACC_IMAGE_DATA,
- TACC_IMAGE_PARAMS,
- TACC_CREATE_DETGEOM,
- TACC_CREATE_BADMAP,
- TACC_CREATE_SATMAP,
- TACC_CACHE_HEADERS,
- TACC_FILTER,
- TACC_RESRANGE,
- TACC_PEAKSEARCH,
- TACC_INDEXING,
- TACC_PREDPARAMS,
- TACC_INTEGRATION,
- TACC_TOTALS,
- TACC_WRITESTREAM,
- TACC_CLEANUP,
- TACC_EVENTWAIT,
- TACC_FINALCLEANUP,
-};
-
-typedef struct _timeaccounts TimeAccounts;
-
-extern TimeAccounts *time_accounts_init(void);
-extern void time_accounts_free(TimeAccounts *accs);
-
-extern void time_accounts_set(TimeAccounts *accs, enum timeaccount new_acc);
-
-extern void time_accounts_reset(TimeAccounts *accs);
-
-extern void time_accounts_print_short(TimeAccounts *accs);
-extern void time_accounts_print(TimeAccounts *accs);
-
-#endif /* TIME_ACCOUNTS_H */