Introduce DC_getResultCPUTime() and add the BOINC implementation

git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@1002 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
gombasg 2007-01-15 14:24:08 +00:00 committed by Adam Visegradi
parent 1197636ed0
commit 49c37a4f42
6 changed files with 38 additions and 45 deletions

View File

@ -103,6 +103,7 @@ struct _DC_Result
DC_Workunit *wu;
int exit_code;
double cpu_time;
/* List of output files. Elements are of type DC_PhysicalFile */
GList *output_files;
@ -158,7 +159,7 @@ int _DC_initWUs(void) G_GNUC_INTERNAL;
/* Creates a new DC_Result */
DC_Result *_DC_createResult(const char *wu_name, int db_id,
const char *xml_doc_in) G_GNUC_INTERNAL;
const char *xml_doc_in, double cpu_time) G_GNUC_INTERNAL;
/* Destroys a DC_Result */
void _DC_destroyResult(DC_Result *result) G_GNUC_INTERNAL;

View File

@ -113,7 +113,8 @@ static int process_results(void)
}
/* Call the callback function */
result = _DC_createResult(wu.name, wu.id, canonical_result.xml_doc_in);
result = _DC_createResult(wu.name, wu.id,
canonical_result.xml_doc_in, canonical_result.cpu_time);
if (!result)
{
mark_wu_complete(wu, TRUE);
@ -302,7 +303,8 @@ static DC_MasterEvent *look_for_results(const char *wuFilter, const char *wuName
event = g_new(DC_MasterEvent, 1);
event->type = DC_MASTER_RESULT;
event->result = _DC_createResult(wu.name, wu.id, result.xml_doc_in);
event->result = _DC_createResult(wu.name, wu.id, result.xml_doc_in,
result.cpu_time);
if (!event->result)
{
mark_wu_complete(wu, FALSE);

View File

@ -25,7 +25,7 @@
*/
DC_Result *_DC_createResult(const char *wu_name, int db_id,
const char *xml_doc_in)
const char *xml_doc_in, double cpu_time)
{
DC_Result *result;
GList *l;
@ -43,6 +43,7 @@ DC_Result *_DC_createResult(const char *wu_name, int db_id,
result->wu->db_id = db_id;
result->wu->state = DC_WU_FINISHED;
result->cpu_time = cpu_time;
result->output_files = _DC_parseFileRefs(xml_doc_in,
&result->num_outputs);
@ -198,3 +199,14 @@ char *DC_getResultOutput(const DC_Result *result, const char *logicalFileName)
g_free(wuname);
return NULL;
}
double DC_getResultCPUTime(const DC_Result *result)
{
if (!result)
{
DC_log(LOG_ERR, "%s: Missing result", __func__);
return 0.0;
}
return result->cpu_time;
}

View File

@ -103,5 +103,6 @@ DC_getResultCapabilities
DC_getResultWU
DC_getResultExit
DC_getResultOutput
DC_getResultCPUTime
</SECTION>

View File

@ -40,7 +40,6 @@ Types of events the master application may receive.
@DC_MASTER_RESULT: a new #DC_Result is available.
@DC_MASTER_SUBRESULT: a subresult has arrived.
@DC_MASTER_MESSAGE: a message has arrived.
@DC_MASTER_SUSPEND: a work unit has been suspended.
<!-- ##### STRUCT DC_Workunit ##### -->
<para>
@ -104,14 +103,6 @@ as invalid.
@message: contents of the message.
<!-- ##### USER_FUNCTION DC_SuspendCallback ##### -->
<para>
Prototype of the callback function used for reporting suspended work units.
</para>
@wu: the work unit that has been suspended.
<!-- ##### FUNCTION DC_initMaster ##### -->
<para>
Initializes the master side of the DC-API. This function must be called first
@ -135,38 +126,6 @@ event.
@msgcb: the callback for reporting messages.
<!-- ##### FUNCTION DC_setMessageCb ##### -->
<para>
Sets the callback function used for reporting messages.
</para>
@cb: the function to call when a message arrives.
<!-- ##### FUNCTION DC_setResultCb ##### -->
<para>
Sets the callback function used for reporting results.
</para>
@cb: the function to call when a result is ready.
<!-- ##### FUNCTION DC_setSubresultCb ##### -->
<para>
Sets the callback function used for reporting subresults.
</para>
@cb: the function to call when a subresult arrives.
<!-- ##### FUNCTION DC_setSuspendCb ##### -->
<para>
Sets the callback function used for reporting suspended work units.
</para>
@cb: the function to call when a work unit has been suspended.
<!-- ##### FUNCTION DC_processMasterEvents ##### -->
<para>
Processes work unit events. In case of a work unit completes and its result is
@ -582,3 +541,18 @@ Returns the real path name for a logical output file name.
string should be deallocated using free() when it is no longer needed.
<!-- ##### FUNCTION DC_getResultCPUTime ##### -->
<para>
Returns the CPU time used for computing the result, in seconds.
<note>
<para>
If redundant computing is enabled, only the CPU time of the canonical
result is returned.
</para>
</note>
</para>
@result: a #DC_Result.
@Returns: the CPU time needed to compute the result.

View File

@ -208,6 +208,9 @@ int DC_getResultExit(const DC_Result *result);
/* Returns the local name of an output file. */
char *DC_getResultOutput(const DC_Result *result, const char *logicalFileName);
/* Returns the CPU time used by the result. */
double DC_getResultCPUTime(const DC_Result *result);
#ifdef __cplusplus
}
#endif