Exemple #1
0
BOOST_TEST_CASE_TEMPLATE_FUNCTION( check_evaluator_with_tag, Info ) {
    typedef typename boost::mpl::at_c< Info, 0 >::type Model;
    typedef typename boost::mpl::at_c< Info, 1 >::type MLE;
    typedef typename boost::mpl::at_c< Info, 2 >::type Data;
    typedef nonlinfit::plane::xs_joint<double, 1>::type RefTag;

    fit_window::Plane plane = mock_data();
    Model z = mock_model<Model>();
    typename guf::PlaneFunction<RefTag>::Evaluators ref_evaluators;
    ref_evaluators.push_back(nonlinfit::plane::create_term(z, RefTag()));
    typename guf::PlaneFunction<Data>::Evaluators tested_evaluators;
    tested_evaluators.push_back(nonlinfit::plane::create_term(z, Data()));
    std::unique_ptr<guf::FitFunction> ref =
        guf::PlaneFunction<RefTag>::create(std::move(ref_evaluators), plane, MLE::value);
    std::unique_ptr<guf::FitFunction> test =
        guf::PlaneFunction<Data>::create(std::move(tested_evaluators), plane, MLE::value);

    bool is_same = nonlinfit::plane::compare_evaluators<double>(*ref->abstract_function(), *test->abstract_function());
    BOOST_CHECK( is_same );
}
Exemple #2
0
static int test(int shape_idx, int type_idx, int dist_idx)
{
    int type = TYPES[type_idx];
    int *dims = SHAPES[shape_idx];
    int ndim = SHAPES_NDIM[shape_idx];
    mock_ga_t *mock_a, *result_a;
    int g_a;
    int buffer[100];
    int lo[GA_MAX_DIM], hi[GA_MAX_DIM], ld[GA_MAX_DIM], shape[GA_MAX_DIM];
    int result=0, error_index=-1, error_proc=-1;

    mock_a = Mock_Create(type, ndim, dims, "mock", NULL);
    result_a = Mock_Create(type, ndim, dims, "mock", NULL);

    g_a = create_function[dist_idx](type, ndim, dims);

    mock_data(mock_a, g_a);

    mock_to_global(mock_a, g_a);

    Mock_Zero(mock_a);

    GA_Zero(g_a);

    global_to_mock(g_a, result_a);

    result = neq_mock(mock_a, result_a, &error_index);
    if (0 != result) {
        error_proc = GA_Nodeid();
    }

    GA_Igop(&result, 1, "+");
    GA_Igop(&error_proc, 1, "max");

    if (error_proc != GA_Nodeid()) {
        error_index = 0;
    }

    GA_Igop(&error_index, 1, "+");
    if (0 != result) {
        if (error_proc == GA_Nodeid()) {
            printf("ERROR: local result failed to compare to global result\n");
            printf("\terror_proc=%d\n", error_proc);
            printf("\terror_index=%d\n", error_index);
            printf("***LOCAL RESULT***\n");
            Mock_Print(mock_a);
            printf("***GLOBAL RESULT***\n");
            Mock_Print(result_a);
            printf("\tprinting array distribution\n");
        }
        GA_Sync();
        GA_Print(g_a);
        GA_Print_distribution(g_a);
        return 1;
    }

    Mock_Destroy(mock_a);
    Mock_Destroy(result_a);
    GA_Destroy(g_a);

    return 0;
}
Exemple #3
0
static int test(int shape_idx, int type_idx, int dist_idx)
{
    int type = TYPES[type_idx];
    int *dims = SHAPES[shape_idx];
    int ndim = SHAPES_NDIM[shape_idx];
    mock_ga_t *mock_a, *result_a;
    int g_a;
    void *alpha = NULL;
    int buffer[100];
    int lo[GA_MAX_DIM], hi[GA_MAX_DIM], ld[GA_MAX_DIM], shape[GA_MAX_DIM];
    int result=0, error_index=-1, error_proc=-1;
    int ival = 6;
    long lval = 7;
    long long llval = 8;
    float fval = 9;
    double dval = 10;
    SingleComplex cval = {11,12};
    DoubleComplex zval = {13,14};

    /* create the local array and result array */
    mock_a = Mock_Create(type, ndim, dims, "mock", NULL);
    result_a = Mock_Create(type, ndim, dims, "mock", NULL);

    /* create the global array */
    g_a = create_function[dist_idx](type, ndim, dims);

    /* create meaningful data for local array */
    mock_data(mock_a, g_a);

    /* init global array with same data as local array */
    mock_to_global(mock_a, g_a);

    switch (type) {
        case C_INT:      alpha = &ival; break;
        case C_LONG:     alpha = &lval; break;
        case C_LONGLONG: alpha = &llval; break;
        case C_FLOAT:    alpha = &fval; break;
        case C_DBL:      alpha = &dval; break;
        case C_SCPL:     alpha = &cval; break;
        case C_DCPL:     alpha = &zval; break;
    }

    /* call the local routine */
    Mock_Add_constant(mock_a, alpha);

    /* call the global routine */
    GA_Add_constant(g_a, alpha);
    
    /* get the results from the global array */
    global_to_mock(g_a, result_a);
    
    /* compare the results */
    result = neq_mock(mock_a, result_a, &error_index);
    if (0 != result) {
        error_proc = GA_Nodeid();
    }
    /* make sure all procs get same result so they can die gracefully */
    GA_Igop(&result, 1, "+");
    /* if error occured, find the highest failing node ID */
    GA_Igop(&error_proc, 1, "max");
    /* clear the error index for all but the highest failing node ID */
    if (error_proc != GA_Nodeid()) {
        error_index = 0;
    }
    /* make sure all procs get the error index on the highest failing node ID */
    GA_Igop(&error_index, 1, "+");
    if (0 != result) {
        if (error_proc == GA_Nodeid()) {
            printf("ERROR: local result failed to compare to global result\n");
            printf("\terror_proc=%d\n", error_proc);
            printf("\terror_index=%d\n", error_index);
            printf("***LOCAL RESULT***\n");
            Mock_Print(mock_a);
            printf("***GLOBAL RESULT***\n");
            Mock_Print(result_a);
            printf("\tprinting array distribution\n");
        }
        GA_Sync();
        GA_Print(g_a);
        GA_Print_distribution(g_a);
        return 1;
    }

    /* clean up */
    Mock_Destroy(mock_a);
    Mock_Destroy(result_a);
    GA_Destroy(g_a);

    return 0;
}
Exemple #4
0
static int test(int shape_idx, int type_idx, int dist_idx)
{
    int type = TYPES[type_idx];
    int *dims = SHAPES[shape_idx];
    int ndim = SHAPES_NDIM[shape_idx];
    mock_ga_t *mock_a, *mock_b, *mock_c, *mock_r;
    int g_a, g_b, g_c;
    int buffer[100];
    int lo[GA_MAX_DIM], hi[GA_MAX_DIM], ld[GA_MAX_DIM], shape[GA_MAX_DIM];
    int result=0, error_index=-1, error_proc=-1;

    mock_a = Mock_Create(type, ndim, dims, "mock", NULL);
    mock_b = Mock_Create(type, ndim, dims, "mock", NULL);
    mock_c = Mock_Create(type, ndim, dims, "mock", NULL);
    mock_r = Mock_Create(type, ndim, dims, "mock", NULL);

    g_a = create_function[dist_idx](type, ndim, dims);
    g_b = create_function[dist_idx](type, ndim, dims);
    g_c = create_function[dist_idx](type, ndim, dims);

    /* create meaningful data for local array */
    mock_data(mock_a, g_a);
    mock_data(mock_b, g_b);

    /* init global array with same data as local array */
    mock_to_global(mock_a, g_a);
    mock_to_global(mock_b, g_b);

    /* call the local routine */
    Mock_Elem_multiply(mock_a, mock_b, mock_c);

    /* call the global routine */
    GA_Elem_multiply(g_a, g_b, g_c);

    /* get the results from the global array */
    global_to_mock(g_c, mock_r);

    /* compare the results */
    result = neq_mock(mock_c, mock_r, &error_index);
    if (0 != result) {
        error_proc = GA_Nodeid();
    }
    /* make sure all procs get same result so they can die gracefully */
    GA_Igop(&result, 1, "+");
    /* if error occured, find the highest failing node ID */
    GA_Igop(&error_proc, 1, "max");
    /* clear the error index for all but the highest failing node ID */
    if (error_proc != GA_Nodeid()) {
        error_index = 0;
    }
    /* make sure all procs get the error index on the highest failing node ID */
    GA_Igop(&error_index, 1, "+");
    if (0 != result) {
        if (error_proc == GA_Nodeid()) {
            printf("ERROR: local result failed to compare to global result\n");
            printf("\terror_proc=%d\n", error_proc);
            printf("\terror_index=%d\n", error_index);
            printf("***LOCAL RESULT***\n");
            Mock_Print(mock_a);
            printf("***GLOBAL RESULT***\n");
            Mock_Print(mock_r);
            printf("\tprinting array distribution\n");
        }
        GA_Sync();
        GA_Print(g_a);
        GA_Print_distribution(g_a);
        return 1;
    }

    /* clean up */
    Mock_Destroy(mock_a);
    Mock_Destroy(mock_r);
    GA_Destroy(g_a);

    return 0;

}