Functions

gs_dag_utils.c File Reference

#include "gs_dag.h"
#include "gs_sequence.h"
Include dependency graph for gs_dag_utils.c:

Go to the source code of this file.

Functions

int output_GS_DAG_to_dot (GS_DAG_t *dag, char *fname)
int verify_object_type (gs_argument_t *argp)
int compare_object (gs_argument_t *largp, gs_argument_t *rargp)
int if_passed_back (va_list arg_list, int n, gs_argument_t *argptr)

Function Documentation

int compare_object ( gs_argument_t *  largp,
gs_argument_t *  rargp 
)

Compare to see if two objects reference to the same data

Parameters:
largp -- left-side object to be compared
rargp -- right-side object to be compared

Definition at line 141 of file gs_dag_utils.c.

                                                               {
    int mode;
    
    mode = grpc_get_sequence_mode();
    
    /* under normal or conservative mode, comparison 
       among scalar argument references is invalid */
    if (mode != RESTRICTIVE_MODE &&
        (largp->objecttype == GS_SCALAR ||
         rargp->objecttype == GS_SCALAR))
        return 1;

    /* under restrictive mode, comparison among
       scalar argument references is valid */
    if (mode == RESTRICTIVE_MODE &&
        (largp->objecttype == GS_SCALAR &&
         rargp->objecttype == GS_SCALAR) &&
        largp->datatype == rargp->datatype) {

    }

    /* comparison among nonscalar argument references */
    if (largp->objecttype == rargp->objecttype &&
        largp->datatype == rargp->datatype &&
        largp->data == rargp->data)
        return 0;

    return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int if_passed_back ( va_list  arg_list,
int  n,
gs_argument_t *  argptr 
)

find out if an argument is required to be passed back by the client user

Definition at line 176 of file gs_dag_utils.c.

                                                                   {
    int i;
    void *arg;

    for (i = 0; i < n; i++) {
        arg = va_arg(arg_list, void*);
        if (argptr->data == arg) return 1;
    }
    va_end(arg_list);

    return 0;
}

Here is the caller graph for this function:

int output_GS_DAG_to_dot ( GS_DAG_t *  dag,
char *  fname 
)

Output a DAG to a dot graph

Parameters:
dag -- the DAG
fname -- the output dot file name
Returns:
0 on success, -1 on failure

Definition at line 20 of file gs_dag_utils.c.

                                                     {
    FILE *fp;
    GS_DAG_Node_t *node;
    GS_DAG_Dep_t *dep;
    char *pnode, *cnode;
    int plevel, clevel;


    if (dag == NULL) {
        fprintf(stderr, "null input DAG\n");
        return -1;
    }

    if (dag->num_nodes == 0 || dag->num_deps == 0) return -1;

    fp = fopen(fname, "w");
    if (fp == NULL) {
        fprintf(stderr, "can't open file %s\n", fname);
        return -1;
    }

    fprintf(fp, "digraph DAG {\n"); /* start */
    /* first output all the nodes (name) */
    for (node = dag->head_node; node != NULL; node = node->next) {
        fprintf(fp, "\t%s_%d;\n", node->func_name, node->sched_level);
    }

    /* next output all the dependencies as edges */
    for (dep = dag->head_dep; dep != NULL; dep = dep->next) {
        /* the name of parent and child nodes */
        pnode = dep->pnode->func_name;
        cnode = dep->cnode->func_name;

        /* the schedulng levels of parent and child nodes */
        plevel = dep->pnode->sched_level;
        clevel = dep->cnode->sched_level;

        /* draw different types of edges for
           different types of dependencies */
        switch (dep->dep_type) {
            case INPUT_AFTER_OUTPUT_DEPENDENCY:
                /* outputs black, forward edge */
                fprintf(fp, 
                "\t%s_%d -> %s_%d [style=bold, label=\"RAW\", fontsize=12];\n",
                pnode, plevel, cnode, clevel);
                break;
            case OUTPUT_AFTER_INPUT_DEPENDENCY:
                /* outputs blue, backward edge */
                fprintf(fp,
                "\t%s_%d -> %s_%d %s;\n",
                pnode, plevel, cnode, clevel,
                "[color=blue, label=\"WAR\", fontcolor=blue, fontsize=12]");
                break;
            case OUTPUT_AFTER_OUTPUT_DEPENDENCY:
                /* outputs red, bi-direction edge */
                fprintf(fp, 
                "\t%s_%d -> %s_%d %s;\n",
                pnode, plevel, cnode, clevel,
                "[color=red, label=\"WAW\", fontcolor=red, fontsize=12]");
                break;
            case CONSERVATIVE_SCALAR_DEPENDENCY:
                /* output green, indirected edge */
                fprintf(fp,
                "\t%s_%d -> %s_%d %s;\n",
                pnode, plevel, cnode, clevel,
                "[color=green, label=\"SCALAR\", fontcolor=green, fontsize=12]");
                break;
            default:
                break;
        }
    }
    fprintf(fp, "}\n"); /* end */
    fclose(fp);
    
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int verify_object_type ( gs_argument_t *  argp  ) 

Verify that if an object is valid for reference comparison

Parameters:
argp -- the object/argument
Returns:
1 on valid, 0 on invalid

Definition at line 106 of file gs_dag_utils.c.

                                            {
    int mode;
    
    mode = grpc_get_sequence_mode();

    /* under conservative mode, scalar arguments
       are invalid for reference verification */
    if (mode == CONSERVATIVE_MODE &&
        argp->objecttype == GS_SCALAR)
        return 0;

    /* under restrictive mode, scalar arguments
       are valid for reference verification */
    if (mode == RESTRICTIVE_MODE &&
        argp->objecttype == GS_SCALAR)
        return 1;

    /* under normal mode, ignore scalar arguments */
    if (argp->objecttype == GS_VECTOR ||
        argp->objecttype == GS_MATRIX ||
        argp->objecttype == GS_SPARSEMATRIX ||
        argp->objecttype == GS_FILE)
        return 1;

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: