commit 6e551f095d0afb9e7a062f5d40fc5d74560596cc
parent 0b5c33d26dd646299db5fa76bf9b96e6ccac39e0
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 5 Oct 2020 11:57:05 +0200
Change the way green estimations report time
Time was reported to be -elapsed_time. Now time is reported to be
INF, with elapsed_time also reported by itself as a new field.
Diffstat:
3 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h
@@ -1028,6 +1028,11 @@ sdis_green_function_for_each_path
sdis_process_green_path_T func,
void* context);
+/* Retrieve the path's elapsed time */
+SDIS_API res_T
+sdis_green_path_get_elapsed_time
+ (struct sdis_green_path* path_handle, double* elapsed);
+
/* Retrieve the spatio-temporal end point of a path used to estimate the green
* function. Note that this point went back in time from the relative
* observation time 0. Its time is thus negative; its absolute value
diff --git a/src/sdis_green.c b/src/sdis_green.c
@@ -77,6 +77,7 @@ flux_term_init(struct mem_allocator* allocator, struct flux_term* term)
#include <rsys/dynamic_array.h>
struct green_path {
+ double elapsed_time;
struct darray_flux_term flux_terms; /* List of flux terms */
struct darray_power_term power_terms; /* List of volumic power terms */
union {
@@ -98,6 +99,7 @@ green_path_init(struct mem_allocator* allocator, struct green_path* path)
ASSERT(path);
darray_flux_term_init(allocator, &path->flux_terms);
darray_power_term_init(allocator, &path->power_terms);
+ path->elapsed_time = -INF;
path->limit.vertex = SDIS_RWALK_VERTEX_NULL;
path->limit.fragment = SDIS_INTERFACE_FRAGMENT_NULL;
path->limit_id = UINT_MAX;
@@ -119,6 +121,7 @@ green_path_copy(struct green_path* dst, const struct green_path* src)
{
res_T res = RES_OK;
ASSERT(dst && src);
+ dst->elapsed_time = src->elapsed_time;
dst->limit = src->limit;
dst->limit_id = src->limit_id;
dst->limit_type = src->limit_type;
@@ -136,6 +139,7 @@ green_path_copy_and_clear(struct green_path* dst, struct green_path* src)
{
res_T res = RES_OK;
ASSERT(dst && src);
+ dst->elapsed_time = src->elapsed_time;
dst->limit = src->limit;
dst->limit_id = src->limit_id;
dst->limit_type = src->limit_type;
@@ -154,6 +158,7 @@ green_path_copy_and_release(struct green_path* dst, struct green_path* src)
{
res_T res = RES_OK;
ASSERT(dst && src);
+ dst->elapsed_time = src->elapsed_time;
dst->limit = src->limit;
dst->limit_id = src->limit_id;
dst->limit_type = src->limit_type;
@@ -180,6 +185,9 @@ green_path_write(const struct green_path* path, FILE* stream)
} \
} (void)0
+ /* Write elapsed time */
+ WRITE(&path->elapsed_time, 1);
+
/* Write the list of flux terms */
sz = darray_flux_term_size_get(&path->flux_terms);
WRITE(&sz, 1);
@@ -227,6 +235,9 @@ green_path_read(struct green_path* path, FILE* stream)
} \
} (void)0
+ /* Read elapsed time */
+ READ(&path->elapsed_time, 1);
+
/* Read the list of flux terms */
READ(&sz, 1);
res = darray_flux_term_resize(&path->flux_terms, sz);
@@ -1116,6 +1127,31 @@ error:
}
res_T
+sdis_green_path_get_elapsed_time
+ (struct sdis_green_path* path_handle, double* elapsed)
+{
+ const struct green_path* path = NULL;
+ struct sdis_green_function* green = NULL;
+ res_T res = RES_OK;
+
+ if(!path_handle || !elapsed) {
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ green = path_handle->green__;
+ ASSERT(path_handle->id__ < darray_green_path_size_get(&green->paths));
+
+ path = darray_green_path_cdata_get(&green->paths) + path_handle->id__;
+ *elapsed = path->elapsed_time;
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
+res_T
sdis_green_path_get_limit_point
(struct sdis_green_path* path_handle, struct sdis_point* pt)
{
@@ -1470,8 +1506,9 @@ green_path_set_limit_interface_fragment
ASSERT(handle->path->limit_type == SDIS_POINT_NONE);
res = ensure_interface_registration(handle->green, interf);
if(res != RES_OK) return res;
+ handle->path->elapsed_time = elapsed_time;
handle->path->limit.fragment = *frag;
- handle->path->limit.fragment.time = -elapsed_time;
+ handle->path->limit.fragment.time = INF;
handle->path->limit_id = interface_get_id(interf);
handle->path->limit_type = SDIS_FRAGMENT;
return RES_OK;
@@ -1489,8 +1526,9 @@ green_path_set_limit_vertex
ASSERT(handle->path->limit_type == SDIS_POINT_NONE);
res = ensure_medium_registration(handle->green, mdm);
if(res != RES_OK) return res;
+ handle->path->elapsed_time = elapsed_time;
handle->path->limit.vertex = *vert;
- handle->path->limit.vertex.time = -elapsed_time;
+ handle->path->limit.vertex.time = INF;
handle->path->limit_id = medium_get_id(mdm);
handle->path->limit_type = SDIS_VERTEX;
return RES_OK;
diff --git a/src/sdis_green.h b/src/sdis_green.h
@@ -21,7 +21,7 @@
/* Current version the green function data structure. One should increment it
* and perform a version management onto serialized data when the gren function
* data structure is updated. */
-static const int SDIS_GREEN_FUNCTION_VERSION = 0;
+static const int SDIS_GREEN_FUNCTION_VERSION = 1;
/* Forward declaration */
struct accum;