Пример #1
0
int btree_find_test(const int argc, const char *const *const argv)
{
	scoped_test_enabler ste(argc, argv);

	log4cxx::Logger::getRootLogger()->setLevel(coherent::log::log_TRACE);

	util::aio_context ctx(4);
	util::async_file f(ctx, "btree_btree_test.btree");

	completion c1, c2, c3;

	test_create_callback tcc(c1);
	btree_creator bc;
	bc.submit_create_btree<int, int>(tcc, f, 1024*1024, 0, 64);
	c1.wait();
	LOG(INFO, "B-tree created on disk.");
	sleep(1);

	test_init_callback tic(c2);
	btree<uint64_t, uint64_t> b(tic, f, 0);
	c2.wait();
	LOG(INFO, "B-tree loaded.");
	LOG(INFO, "metadata: "
		<< " page_size=" << b.impl->m.page_size
	);
	sleep(1);

	test_find_callback tfc(c3);
	b.submit_find(tfc, 0);
	c3.wait();
	LOG(INFO, "Find performed.");

	return 0;
}
Пример #2
0
// Return the patch face neighbour cell centres
Foam::tmp<Foam::vectorgpuField> Foam::polyPatch::getFaceCellCentres() const
{
    tmp<vectorgpuField> tcc(new vectorgpuField(size()));
    vectorgpuField& cc = tcc();

    // get reference to global cell centres
    const vectorgpuField& gcc = boundaryMesh_.mesh().getCellCentres();

    const labelgpuList& faceCells = this->getFaceCells();

    thrust::copy(thrust::make_permutation_iterator(gcc.begin(),faceCells.begin()),
                 thrust::make_permutation_iterator(gcc.begin(),faceCells.end()),
                 cc.begin());

    return tcc;
}
Пример #3
0
// Return the patch face neighbour cell centres
Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const
{
    tmp<vectorField> tcc(new vectorField(size()));
    vectorField& cc = tcc();

    // get reference to global cell centres
    const vectorField& gcc = boundaryMesh_.mesh().cellCentres();

    const labelUList& faceCells = this->faceCells();

    forAll(faceCells, facei)
    {
        cc[facei] = gcc[faceCells[facei]];
    }

    return tcc;
}
Пример #4
0
inline void smooth_tcc()
{
    for(auto variable : tcc_lookup_)
    {
        tcc(variable) =
            tcc_type((static_cast<double>(tcc(variable)) * 0.3) + 1.0);

        if(tcc(variable) <= tcc_type(2))
            temp_.push_back(variable);
    }

    for(auto variable : temp_)
        tcc_lookup_.remove(variable);

    // TODO: Fix this!!!
    temp_.reset();
}
Пример #5
0
/*
    Sets up the TCC module to send PWM output to the PWR LED
*/
void init_breathing_animation() {
    // Setup the pin to be used as a TCC output
    pin_mux(PIN_LED);
    pin_dir(PIN_LED, true);

    // Disable the TCC
    tcc(PWR_LED_TCC_CHAN)->CTRLA.reg = 0;

    // Reset the TCC
    tcc(PWR_LED_TCC_CHAN)->CTRLA.reg = TCC_CTRLA_SWRST;

    // Enable the timer
    timer_clock_enable(PWR_LED_TCC_CHAN);

    /* Set the prescalar setting to the highest division so we have more time
        in between interrupts to complete the math
    */
    tcc(PWR_LED_TCC_CHAN)->CTRLA.bit.PRESCALER = TCC_CTRLA_PRESCALER_DIV1024_Val;

    // Set the waveform generator to generate a PWM signal
    // It uses polarity setting of 1 (switches from DIR to ~DIR)
    tcc(PWR_LED_TCC_CHAN)->WAVE.reg = TCC_WAVE_WAVEGEN_NPWM | TCC_WAVE_POL0;

    // Set the top count value (when a match will be hit and the waveform output flipped)
    tcc(PWR_LED_TCC_CHAN)->PER.reg = MAX_COUNTER;

    // Set the counter number, starting at 0% duty cycle
    tcc(PWR_LED_TCC_CHAN)->CC[PWR_LED_CC_CHAN].reg = counter;

    // Set the second CCB value value be dark for simplicity
    tcc(PWR_LED_TCC_CHAN)->CCB[PWR_LED_CC_CHAN].bit.CCB = counter;

    // Enable IRQ's in the NVIC
    NVIC_EnableIRQ(TCC1_IRQn);
    // Set the priority to low
    NVIC_SetPriority(TCC1_IRQn, 0xff);
    // Enable interrupts so we can modify the counter value (creates breathing effect)
    tcc(PWR_LED_TCC_CHAN)->INTENSET.reg = TC_INTENSET_OVF;

    // Wait for all the changes to finish loading?
    while (tcc(PWR_LED_TCC_CHAN)->SYNCBUSY.reg > 0);

    // Enable the TCC
    tcc(PWR_LED_TCC_CHAN)->CTRLA.reg = TCC_CTRLA_ENABLE;
}
Пример #6
0
/*
    Reset the TCC module after breathing completes and stop interrupts
*/
void cancel_breathing_animation() {
    // Disable the TCC
    tcc(PWR_LED_TCC_CHAN)->CTRLA.reg = TCC_CTRLA_RESETVALUE;
    // Disable Boot LED TCC IRQ in the NVIC
    NVIC_DisableIRQ(TCC1_IRQn);
    // Set the PWR LED to the default high state
    pin_out(PIN_LED);
    pin_high(PIN_LED);
}
Пример #7
0
/*
    Handler for the POWER LED breathing animation
*/
void TCC1_Handler() {
    // booted is true when the coprocess first gets
    // a status packet from the spi daemon
    if (booted == true) {
        // Stop this breathing animation and cancel interrupts
        cancel_breathing_animation();
    }

    // Take that proportion and extract a point along the sudo sine wave
    tcc(PWR_LED_TCC_CHAN)->CCB[PWR_LED_CC_CHAN].bit.CCB = interpolate(++counter);
}
Пример #8
0
void TCC_HANDLER(TCC_PORT_B) {
    uart_send_data(&port_b);

    // clear irq
    tcc(TCC_PORT_B)->INTFLAG.reg = TCC_INTENSET_OVF;
}
Пример #9
0
inline void reset_tcc(variable_type variable)
{
    tcc(variable) = tcc_type(0);
    send_signal(tcc_reset, variable);
}
Пример #10
0
inline void dec_tcc(variable_type variable, tcc_type diff)
{
    tcc(variable) -= diff;
    send_signal(tcc_dec, variable, diff);
}
Пример #11
0
inline void inc_tcc(variable_type variable, tcc_type diff)
{
    tcc(variable) += diff;
    send_signal(tcc_inc, variable, diff);
}