Exemplo n.º 1
0
static int
qaff_w_mkpath(lua_State *L)
{
    mAffWriter *b = qlua_checkAffWriter(L, 1);
    const char *p = luaL_checkstring(L, 2);
    struct AffNode_s *r;
    int status;

    check_writer(L, b);

    qlua_Aff_enter(L);
    if (b->master) {
        r = qlua_AffWriterMkPath(b, p);
        status = (r != NULL);
    } else {
        status = 0;
    }
    qlua_Aff_leave();
    QMP_sum_int(&status);
    
    if (status)
        return 0;

    if (b->master)
        return luaL_error(L, aff_writer_errstr(b->ptr));
    else
        return luaL_error(L, "generic writer error");
}
Exemplo n.º 2
0
static int
q_aff_writer(lua_State *L)
{
    const char *name = luaL_checkstring(L, 1);
    struct AffWriter_s *w;
    const char *msg;
    int status;

    qlua_Aff_enter(L);
    if (QDP_this_node == qlua_master_node) {
        w = aff_writer(name);
        msg = aff_writer_errstr(w);
        if (msg == NULL) {
            qlua_newAffWriter(L, w);
            status = 1;
        } else {
            aff_writer_close(w);
            status = 0;
        }
    } else {
        qlua_newAffWriter(L, NULL);
        msg = "generic writer error";
        status = 0;
    }
    qlua_Aff_leave();
    QMP_sum_int(&status);

    if (status)
        return 1;

    return luaL_error(L, msg);
}
Exemplo n.º 3
0
static int
qaff_w_status(lua_State *L)
{
    mAffWriter *b = qlua_checkAffWriter(L, 1);
    const char *s;
    int status;
    
    check_writer(L, b);

    qlua_Aff_enter(L);
    if (b->master) {
        s = aff_writer_errstr(b->ptr);
        status = s == NULL;
    } else {
        s = "generic writer error";
        status = 0;
    }
    qlua_Aff_leave();
    QMP_sum_int(&status);

    if (status)
        lua_pushnil(L);
	else
		lua_pushstring(L, s);

    return 1;
}
Exemplo n.º 4
0
void DML_sync(void){

  int my_int=5;
  /*  QMP_barrier(); */
  QMP_sum_int(&my_int);

}
Exemplo n.º 5
0
void
XMP_dist_int_array(int src_node, int count, int *data)
{
    int i;

    if (src_node != QDP_this_node)
        memset(data, 0, count * sizeof (int));
    for (i = 0; i < count; i++)
        QMP_sum_int(&data[i]);
}
Exemplo n.º 6
0
void comm_allreduce_int(int* data)
{
  QMP_CHECK( QMP_sum_int(data) );
}
Exemplo n.º 7
0
static int
qaff_w_write(lua_State *L)
{
    mAffWriter *b = qlua_checkAffWriter(L, 1);
    const char *p = luaL_checkstring(L, 2);
    struct AffNode_s *n;
    int status;
    const char *msg = NULL;

    check_writer(L, b);

    qlua_Aff_enter(L);

    if (b->master) {
        status = 0;
        n = qlua_AffWriterMkPath(b, p);
        if (n == 0) {
            msg = aff_writer_errstr(b->ptr);
            goto end;
        }

        msg = "Write error";
        switch (qlua_qtype(L, 3)) {
        case qString: {
            const char *str = luaL_checkstring(L, 3);
            
            if (aff_node_put_char(b->ptr, n, str, strlen(str)) == 0)
                status = 1;
            
            break;
        }
        case qVecInt: {
            mVecInt *v = qlua_checkVecInt(L, 3);
            int size = v->size;
            uint32_t *d = qlua_malloc(L, size * sizeof (uint32_t));
            int i;

            for (i = 0; i < size; i++)
                d[i] = v->val[i];
            if (aff_node_put_int(b->ptr, n, d, size) == 0)
                status = 1;

			qlua_free(L, d);
            break;

        }
        case qVecReal: {
            mVecReal *v = qlua_checkVecReal(L, 3);
            int size = v->size;
            double *d = qlua_malloc(L, size * sizeof (double));
            int i;

            for (i = 0; i < size; i++)
                d[i] = v->val[i];
            if (aff_node_put_double(b->ptr, n, d, size) == 0)
                status = 1;

			qlua_free(L, d);
            break;
        }
        case qVecComplex: {
            mVecComplex *v = qlua_checkVecComplex(L, 3);
            int size = v->size;
            double _Complex *d = qlua_malloc(L, size * sizeof (double _Complex));
            int i;

            for (i = 0; i < size; i++) {
                d[i] = QLA_real(v->val[i]) + I * QLA_imag(v->val[i]);
            }
            if (aff_node_put_complex(b->ptr, n, d, size) == 0)
                status = 1;

			qlua_free(L, d);
            break;
        }
        default:
            msg = "Unsupported data type";
            break;
        }
    end:
        ;
    } else {
        status = 0;
    }
    qlua_Aff_leave();
    QMP_sum_int(&status);

    if (status)
        return 0;

    if (b->master)
        return luaL_error(L, msg);
    else
        return luaL_error(L, "generic writer error");
}
Exemplo n.º 8
0
/* Sum an int over all nodes (16 or 32 bit) */
void DML_sum_int(int *ipt)
{
  int work = *ipt;
  QMP_sum_int(&work);
  *ipt = work;
}