Jump to content


Pipelining problem when closing streams


  • You cannot reply to this topic
2 replies to this topic

#1 Diego

    Member

  • Members
  • PipPip
  • 11 posts

Posted 21 February 2010 - 12:20 PM

Hi, I have a hw design with three process.

The first one reads data, performs some initial computations and push data to the second process, which is pipelined. The third process read data from the pipelined process, performs some final computations and write the results.

Once I've finished to push data in the pipelined process i'm closing the input stream so that the pipeline get flushed. However, with Stage Master Debugger I'm seeing that only the first iteration works well. In the second iteration i'm seeing the pipeline doesn't get filled correctly and process is always returning 1.

Below there is a skeleton of my code. I hope you can help me to see what i'm doing wrong.

Thanks in advance and Kind Regards,

Diego.



CODE
void preProc(co_stream inputstr, co_stream outputstr, co_signal go, co_signal fin) {

    int goData;

    //Input/output vars
    co_uint32 nSample;

    IF_SIM(cosim_logwindow log;)
    IF_SIM(log = cosim_logwindow_create("preProc");)


    do { // Hardware processes run forever
        co_stream_open(inputstr, O_RDONLY, UINT_TYPE(STREAMWIDTH));
        co_stream_open(outputstr, O_WRONLY, UINT_TYPE(STREAMWIDTH));

        // Read values from the stream
        while (co_stream_read(inputstr, &nSample, sizeof ( co_uint32)) == co_err_none) {
            //Some computation
            co_par_break();
            co_signal_post(go, 1); //Notify postProc to start


            //More computations
            co_par_break();

            //Send data to upwind
            co_stream_write(outputstr, &nSample, sizeof ( co_uint32));
            co_stream_write(outputstr, &nSample, sizeof ( co_uint32));
            co_stream_write(outputstr, &nSample, sizeof ( co_uint32));
            co_stream_write(outputstr, &nSample, sizeof ( co_uint32));
            co_stream_close(outputstr); //to flush pipeline

            co_par_break(); //wait to avoid inter-blocking (?)
            co_signal_wait(fin, &goData); // Wait for postProc to finish

        }
        co_stream_close(inputstr);

    } while (1);
}

void postProc(co_stream inputstr, co_stream outputstr, co_signal go, co_signal fin) {
    //Input/output vars
    co_uint32 nSample;


    int goData;

    IF_SIM(cosim_logwindow log;)
    IF_SIM(log = cosim_logwindow_create("postProc");)


    do { // Hardware processes run forever
        co_stream_open(inputstr, O_RDONLY, UINT_TYPE(STREAMWIDTH));
        co_stream_open(outputstr, O_WRONLY, UINT_TYPE(STREAMWIDTH));

        co_signal_wait(go, &goData); // Wait for preProc to read data problem numbers
        co_par_break();
        co_par_break();
        co_par_break();
        co_par_break();
        co_par_break();
        co_stream_read(inputstr, &nSample, sizeof ( co_uint32));
        co_stream_read(inputstr, &nSample, sizeof ( co_uint32));
        co_stream_read(inputstr, &nSample, sizeof ( co_uint32));
        co_stream_read(inputstr, &nSample, sizeof ( co_uint32));
        co_signal_post(fin, 1);

        co_stream_close(inputstr);
        co_stream_close(outputstr);

    } while (1);

}

void upwind_residuals(co_stream inputResStr, co_stream outputResStr) {

    co_uint32 salida, nSample;

    IF_SIM(int samplesread; int sampleswritten;)

    IF_SIM(cosim_logwindow log;)
    IF_SIM(log = cosim_logwindow_create("upwind");)

    do { // Hardware processes run forever
        IF_SIM(samplesread = 0; sampleswritten = 0;)

                co_stream_open(inputResStr, O_RDONLY, UINT_TYPE(STREAMWIDTH));
        co_stream_open(outputResStr, O_WRONLY, UINT_TYPE(STREAMWIDTH));
        salida = 0;

        // Read values from the stream
        while (co_stream_read(inputResStr, &nSample, sizeof ( co_uint32)) == co_err_none) {
            #pragma CO PIPELINE
            IF_SIM(samplesread++;)
            salida++;
            co_par_break();
            co_par_break();
            co_par_break();
            co_par_break();
            co_par_break();
            co_stream_write(outputResStr, &salida, sizeof ( co_uint32));
            //IF_SIM(cosim_logwindow_fwrite(log, "Instance %d wrote value %x\n", nInstance, nSample);)
            IF_SIM(sampleswritten++;)
        }
        co_stream_close(inputResStr);
        co_stream_close(outputResStr);
        IF_SIM(cosim_logwindow_fwrite(log,
                "Closing filter process (instance %d), samples read: %d, samples written: %d\n",
                0/*nInstance*/, samplesread, sampleswritten);)

                IF_SIM(break;) // Only run once for desktop simulation
    } while (1);
}


#2 etrexel

    Advanced Member

  • Impulse Staff
  • PipPipPip
  • 260 posts

Posted 21 February 2010 - 04:15 PM

Hi Diego,
Only thing that potentially doesn't look balanced in terms of co_stream_open/close() is in preProc() where co_stream_close(outputstr); is inside the loop and could be called more than once depending upon the input data. Is co_stream_close(outputstr); being called only once?
If that didn't help: What version of CoDeveloper are you running? And would it be possible to have you send a complete set of CoDeveloper projects to support@impulsec.com in order to reproduce the symptom?

Best Regards,
Ed
Ed Trexel
Impulse Accelerated Technologies, Inc.

#3 Diego

    Member

  • Members
  • PipPip
  • 11 posts

Posted 22 February 2010 - 01:15 AM

QUOTE (etrexel @ Feb 22 2010, 01:15 AM) <{POST_SNAPBACK}>
Hi Diego,
Only thing that potentially doesn't look balanced in terms of co_stream_open/close() is in preProc() where co_stream_close(outputstr); is inside the loop and could be called more than once depending upon the input data. Is co_stream_close(outputstr); being called only once?
If that didn't help: What version of CoDeveloper are you running? And would it be possible to have you send a complete set of CoDeveloper projects to support@impulsec.com in order to reproduce the symptom?

Best Regards,
Ed


Hi etrexel,

As far as I can see, opennings and closings are balanced. I'm using 3.60.d6 version. I've just sent you an email with the sample project.

Thank you very much.

Best regards,
Diego.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users