Exemplo n.º 1
0
void LTSor::produceOutput() {

	// wait for the input producer to flag us.
	tuple* tmpFlag = make_tuple("s", SOR_FLAG);
	tuple* flag = get_tuple(tmpFlag, &ctx);

	// grab the solution tuple and copy it to the output
	tuple *templateSolutionTuple = make_tuple("s?", SOLUTION_VECTOR);
	tuple *solutionTuple = read_tuple(templateSolutionTuple, &ctx);
	memcpy(outputs[0],
		solutionTuple->elements[1].data.s.ptr,
		solutionTuple->elements[1].data.s.len);

	// remove the tuple synch lock from tuple space
	tuple *synchLock = make_tuple("s", SYNCH_LOCK);
	get_tuple(synchLock, &ctx);

	// clean-up
	destroy_tuple(tmpFlag);
	destroy_tuple(flag);
	destroy_tuple(templateSolutionTuple);
	destroy_tuple(solutionTuple);
	destroy_tuple(synchLock);

}
Exemplo n.º 2
0
VALUE read_large_tuple(unsigned char **pData, VALUE forceToEncoding) {
  if(read_1(pData) != ERL_LARGE_TUPLE) {
    rb_raise(rb_eStandardError, "Invalid Type, not a large tuple");
  }

  unsigned int arity = read_4(pData);
  return read_tuple(pData, arity, forceToEncoding);
}
Exemplo n.º 3
0
VALUE read_small_tuple(unsigned char **pData, VALUE forceToEncoding) {
  if(read_1(pData) != ERL_SMALL_TUPLE) {
    rb_raise(rb_eStandardError, "Invalid Type, not a small tuple");
  }

  int arity = read_1(pData);
  return read_tuple(pData, arity, forceToEncoding);
}
Exemplo n.º 4
0
AST_expr* readASTExpr(BufferedReader* reader) {
    uint8_t type = reader->readByte();
    if (VERBOSITY("parsing") >= 2)
        printf("type = %d\n", type);
    if (type == 0)
        return NULL;

    uint8_t checkbyte = reader->readByte();
    assert(checkbyte == 0xae);

    switch (type) {
        case AST_TYPE::Attribute:
            return read_attribute(reader);
        case AST_TYPE::BinOp:
            return read_binop(reader);
        case AST_TYPE::BoolOp:
            return read_boolop(reader);
        case AST_TYPE::Call:
            return read_call(reader);
        case AST_TYPE::Compare:
            return read_compare(reader);
        case AST_TYPE::Dict:
            return read_dict(reader);
        case AST_TYPE::DictComp:
            return read_dictcomp(reader);
        case AST_TYPE::IfExp:
            return read_ifexp(reader);
        case AST_TYPE::Index:
            return read_index(reader);
        case AST_TYPE::Lambda:
            return read_lambda(reader);
        case AST_TYPE::List:
            return read_list(reader);
        case AST_TYPE::ListComp:
            return read_listcomp(reader);
        case AST_TYPE::Name:
            return read_name(reader);
        case AST_TYPE::Num:
            return read_num(reader);
        case AST_TYPE::Repr:
            return read_repr(reader);
        case AST_TYPE::Slice:
            return read_slice(reader);
        case AST_TYPE::Str:
            return read_str(reader);
        case AST_TYPE::Subscript:
            return read_subscript(reader);
        case AST_TYPE::Tuple:
            return read_tuple(reader);
        case AST_TYPE::UnaryOp:
            return read_unaryop(reader);
        default:
            fprintf(stderr, "Unknown expr node type (parser.cpp:" STRINGIFY(__LINE__) "): %d\n", type);
            abort();
            break;
    }
}
Exemplo n.º 5
0
VALUE read_dict_pair(unsigned char **pData, VALUE forceToEncoding) {
  if(read_1(pData) != ERL_SMALL_TUPLE) {
    rb_raise(rb_eStandardError, "Invalid dict pair, not a small tuple");
  }

  int arity = read_1(pData);

  if(arity != 2) {
    rb_raise(rb_eStandardError, "Invalid dict pair, not a 2-tuple");
  }

  return read_tuple(pData, arity, forceToEncoding);
}
Exemplo n.º 6
0
static Tuple *
ffaudio_probe_for_tuple(const gchar *filename, VFSFile *fd)
{
    if (! fd)
        return NULL;

    Tuple * t = read_tuple (filename, fd);
    if (t == NULL)
        return NULL;

    if (! vfs_fseek (fd, 0, SEEK_SET))
        tag_tuple_read (t, fd);

    return t;
}
Exemplo n.º 7
0
void LTRandmat::work() {

	tuple *recv = make_tuple("s?", REQUEST);
	tuple *tmpInit = make_tuple("s?", "randmat state");
	tuple *init = NULL;
	IntVector initVector = NULL;
	
	// satisfy randmat requests.
	while (1) {

		// block until we receive a tuple.
		tuple* gotten = get_tuple(recv, &ctx);

		// grab a copy of the initializer, tuple if we haven't already
		if (!init) {
			init = read_tuple(tmpInit, &ctx);
			initVector = (IntVector) init->elements[1].data.s.ptr;
		}

		// copy over row co-ordinate of the computation; create
		// a buffer for the results of the computation.
		size_t row = gotten->elements[1].data.i;
		tuple *send = make_tuple("sis", "randmat done", row, "");
		IntVector buffer = (IntVector) NEW_VECTOR_SZ(INT_TYPE, RANDMAT_NC);
		send->elements[2].data.s.len = sizeof(INT_TYPE) * RANDMAT_NC;
		send->elements[2].data.s.ptr = (char*) buffer;

		// perform the actual computation for this row.
		buffer[0] = VECTOR(initVector, row);
		for (int x = 1; x < RANDMAT_NC; ++x) {
			buffer[x] = (aPrime * buffer[x-1] + cPrime) % RAND_M;
		}
	
		// send off the new tuple and purge local memory of the one we got
		put_tuple(send, &ctx);
		destroy_tuple(gotten);
		destroy_tuple(send);
		delete[] buffer;

	}

	// TODO destroy the template tuples; must send tuples for this
//	destroy_tuple(recv);

}
Exemplo n.º 8
0
static void setup_regions(client_handle_t handle, int attr,
			  memory_handle_t *list)
{
    int i, code, has_jedec, has_geo;
    u_int offset;
    cistpl_device_t device;
    cistpl_jedec_t jedec;
    cistpl_device_geo_t geo;
    memory_handle_t r;

    DEBUG(1, "cs: setup_regions(0x%p, %d, 0x%p)\n",
	  handle, attr, list);

    code = (attr) ? CISTPL_DEVICE_A : CISTPL_DEVICE;
    if (read_tuple(handle, code, &device) != CS_SUCCESS)
	return;
    code = (attr) ? CISTPL_JEDEC_A : CISTPL_JEDEC_C;
    has_jedec = (read_tuple(handle, code, &jedec) == CS_SUCCESS);
    if (has_jedec && (device.ndev != jedec.nid)) {
#ifdef PCMCIA_DEBUG
	printk(KERN_DEBUG "cs: Device info does not match JEDEC info.\n");
#endif
	has_jedec = 0;
    }
    code = (attr) ? CISTPL_DEVICE_GEO_A : CISTPL_DEVICE_GEO;
    has_geo = (read_tuple(handle, code, &geo) == CS_SUCCESS);
    if (has_geo && (device.ndev != geo.ngeo)) {
#ifdef PCMCIA_DEBUG
	printk(KERN_DEBUG "cs: Device info does not match geometry tuple.\n");
#endif
	has_geo = 0;
    }
    
    offset = 0;
    for (i = 0; i < device.ndev; i++) {
	if ((device.dev[i].type != CISTPL_DTYPE_NULL) &&
	    (device.dev[i].size != 0)) {
	    r = kmalloc(sizeof(*r), GFP_KERNEL);
	    r->region_magic = REGION_MAGIC;
	    r->state = 0;
	    r->dev_info[0] = '\0';
	    r->mtd = NULL;
	    r->info.Attributes = (attr) ? REGION_TYPE_AM : 0;
	    r->info.CardOffset = offset;
	    r->info.RegionSize = device.dev[i].size;
	    r->info.AccessSpeed = device.dev[i].speed;
	    if (has_jedec) {
		r->info.JedecMfr = jedec.id[i].mfr;
		r->info.JedecInfo = jedec.id[i].info;
	    } else
		r->info.JedecMfr = r->info.JedecInfo = 0;
	    if (has_geo) {
		r->info.BlockSize = geo.geo[i].buswidth *
		    geo.geo[i].erase_block * geo.geo[i].interleave;
		r->info.PartMultiple =
		    r->info.BlockSize * geo.geo[i].partition;
	    } else
		r->info.BlockSize = r->info.PartMultiple = 1;
	    r->info.next = *list; *list = r;
	}
	offset += device.dev[i].size;
    }
} /* setup_regions */
Exemplo n.º 9
0
void LTSor::work() {

	// tuple templates
	tuple *synchLock = make_tuple("s", SYNCH_LOCK);
	tuple *recv = make_tuple("s??", "sor request");

	// grab pointers locally.
	Matrix matrix = (Matrix) inputs[0];

	while (1) {

		// block until we receieve a tuple.
		tuple* gotten = get_tuple(recv, &ctx);
		index_t row = gotten->elements[1].data.i;
		index_t start = gotten->elements[2].data.i;
		index_t stop = gotten->elements[3].data.i;

		// grab the solution tuple
		tuple *templateSolutionTuple = make_tuple("s?", SOLUTION_VECTOR);
		tuple *solutionTuple = read_tuple(templateSolutionTuple, &ctx);
		destroy_tuple(templateSolutionTuple);
		Vector solution = (Vector) solutionTuple->elements[1].data.s.ptr;

		// sum part of the matrix row with the corresponding elements
		// in the solution vector.
		real sum = 0.0;
		for (index_t col = start; col < stop; ++col) {
			if (col != row) {
				sum += MATRIX_SQUARE_N(matrix, row, col, SOR_N) * VECTOR(solution, col);
			}
		}

		// purge local memory of the tuple we received
		destroy_tuple(gotten);

		// Now, we combine the results from these elements with the "world".
		// enter the critical section
		get_tuple(synchLock, &ctx);

			// combine results with master copy (sum)
			tuple *tmpSum = make_tuple("s?", SOLUTION_SUM);
			tuple *tupleSum = get_tuple(tmpSum, &ctx);
			tmpSum->elements[1].data.d = sum + tupleSum->elements[1].data.d;
			put_tuple(tmpSum, &ctx);
			destroy_tuple(tmpSum);
			destroy_tuple(tupleSum);

			// record the number of rows reporting
			tuple *templateRowsReporting = make_tuple("s?", ROWS_DONE);
			tuple *rowsReporting = get_tuple(templateRowsReporting, &ctx);
			rowsReporting->elements[1].data.i += (stop - start);
			put_tuple(rowsReporting, &ctx);
			destroy_tuple(templateRowsReporting);
			destroy_tuple(rowsReporting);

		// leave the critical section
		put_tuple(synchLock, &ctx);

	}

}