Exemplo n.º 1
0
    /** ============================================================================
     *  @func   helloDSP_Execute
     *
     *  @desc   This function implements the execute phase for this application.
     *
     *  @modif  None
     *  ============================================================================
     */
    NORMAL_API DSP_STATUS helloDSP_Execute(IN Uint32 numIterations, Uint8 processorId)
    {
        DSP_STATUS  status = DSP_SOK;
        Uint16 sequenceNumber = 0;
        Uint16 msgId = 0;
        Uint32 i;
        ControlMsg *msg;

        SYSTEM_0Print("Entered helloDSP_Execute ()\n");

#if defined (PROFILE)
        SYSTEM_GetStartTime();
#endif

        for (i = 1 ; ((numIterations == 0) || (i <= (numIterations + 1))) && (DSP_SUCCEEDED (status)); i++)
        {
            /* Receive the message. */
            status = MSGQ_get(SampleGppMsgq, WAIT_FOREVER, (MsgqMsg *) &msg);
            if (DSP_FAILED(status))
            {
                SYSTEM_1Print("MSGQ_get () failed. Status = [0x%x]\n", status);
            }
#if defined (VERIFY_DATA)
            /* Verify correctness of data received. */
            if (DSP_SUCCEEDED(status))
            {
                status = helloDSP_VerifyData(msg, sequenceNumber);
                if (DSP_FAILED(status))
                {
                    MSGQ_free((MsgqMsg) msg);
                }
            }
#endif

            if (msg->command == 0x01)
                SYSTEM_1Print("Message received: %s\n", (Uint32) msg->arg1);
            else if (msg->command == 0x02)
                SYSTEM_1Print("Message received: %s\n", (Uint32) msg->arg1);

            /* If the message received is the final one, free it. */
            if ((numIterations != 0) && (i == (numIterations + 1)))
            {
                MSGQ_free((MsgqMsg) msg);
            }
            else
            {
                /* Send the same message received in earlier MSGQ_get () call. */
                if (DSP_SUCCEEDED(status))
                {
                    msgId = MSGQ_getMsgId(msg);
                    MSGQ_setMsgId(msg, msgId);
                    status = MSGQ_put(SampleDspMsgq, (MsgqMsg) msg);
                    if (DSP_FAILED(status))
                    {
                        MSGQ_free((MsgqMsg) msg);
                        SYSTEM_1Print("MSGQ_put () failed. Status = [0x%x]\n", status);
                    }
                }

                sequenceNumber++;
                /* Make sure that the sequenceNumber stays within the permitted
                 * range for applications. */
                if (sequenceNumber == MSGQ_INTERNALIDSSTART)
                {
                    sequenceNumber = 0;
                }

#if !defined (PROFILE)
                if (DSP_SUCCEEDED(status) && ((i % 100) == 0))
                {
                    SYSTEM_1Print("Transferred %ld messages\n", i);
                }
#endif
            }
        }

#if defined (PROFILE)
        if (DSP_SUCCEEDED(status))
        {
            SYSTEM_GetEndTime();
            SYSTEM_GetProfileInfo(numIterations);
        }
#endif

        SYSTEM_0Print("Leaving helloDSP_Execute ()\n");

        return status;
    }
Exemplo n.º 2
0
    /** ============================================================================
     *  @func   helloDSP_Execute
     *
     *  @desc   This function implements the execute phase for this application.
     *
     *  @modif  None
     *  ============================================================================
     */
    NORMAL_API DSP_STATUS helloDSP_Execute(IN Uint32 numIterations, Uint8 processorId)
    {
        DSP_STATUS  status = DSP_SOK;
        Uint16 sequenceNumber = 0;
        Uint16 msgId = 0;
        Uint8 i,j,k, count;
        ControlMsg *msg;
        Uint16 A[SIZE][SIZE], B[SIZE][SIZE];
        Uint8 step_select;
        step_select = SIZE % 2;

        SYSTEM_0Print("Entered helloDSP_Execute ()\n");

        //Create Matrix
        for (j = 0; j < SIZE; j++)
                    {
                        for (k = 0; k < SIZE; k++)
                        {
                            A[j][k] = 1;
                            B[j][k] = 2;
                        }
                    }


#if defined (PROFILE)
        SYSTEM_GetStartTime();
#endif
        status = MSGQ_get(SampleGppMsgq, WAIT_FOREVER, (MsgqMsg *) &msg);
                if (DSP_FAILED(status))
                {
                    SYSTEM_1Print("MSGQ_get () failed. Status = [0x%x]\n", status);
                }
    #if defined (VERIFY_DATA)
                /* Verify correctness of data received. */
                if (DSP_SUCCEEDED(status))
                {
                    status = helloDSP_VerifyData(msg, sequenceNumber);
                    if (DSP_FAILED(status))
                    {
                        MSGQ_free((MsgqMsg) msg);
                    }
                }
    #endif

        SYSTEM_1Print("Message received: %s\n", (Uint32) msg->arg1);

        for (i = 1 ; ((numIterations == 0) || (i < (numIterations + 1))) && (DSP_SUCCEEDED (status)); i++)
        {
            count = 0;
            while(count < 2)
            {       
                /* If the message received is the final one, free it. */
                if ((numIterations != 0) && (i == (numIterations + 1)))
                {
                    MSGQ_free((MsgqMsg) msg);
                }
                else
                {
                    if(count == 0)
                    {   msg->row = SIZE/2;
                        msg->col = SIZE;
                        for (j = 0; j < SIZE/2; j++)
                        {
                            for (k = 0; k < SIZE; k++)
                            {
                                msg->mat[j+SIZE/2 + step_select][k] = A[j+ SIZE/2 + step_select][k];
                            }
                        }
                    }

                    if(count == 1)
                    {   msg->row = SIZE;
                        msg->col = SIZE;
                        for (j = 0; j < SIZE; j++)
                        {
                            for (k = 0; k < SIZE; k++)
                            {
                                msg->mat[j][k] = B[j][k];
                            }
                        }
                    }                
                    
                    /* Send the same message received in earlier MSGQ_get () call. */
                    if (DSP_SUCCEEDED(status))
                    {
                        msgId = MSGQ_getMsgId(msg);
                        MSGQ_setMsgId(msg, msgId);
                        status = MSGQ_put(SampleDspMsgq, (MsgqMsg) msg);
                        if (DSP_FAILED(status))
                        {
                            MSGQ_free((MsgqMsg) msg);
                            SYSTEM_1Print("MSGQ_put () failed. Status = [0x%x]\n", status);
                        }
                    }

                    sequenceNumber++;
                    /* Make sure that the sequenceNumber stays within the permitted
                     * range for applications. */
                    if (sequenceNumber == MSGQ_INTERNALIDSSTART)
                    {
                        sequenceNumber = 0;
                    }

    #if !defined (PROFILE)
                    if (DSP_SUCCEEDED(status) && ((i % 100) == 0))
                    {
                        SYSTEM_1Print("Transferred %ld messages\n", i);
                    }
    #endif
                        /* Receive the message. */
                    status = MSGQ_get(SampleGppMsgq, WAIT_FOREVER, (MsgqMsg *) &msg);
                    if (DSP_FAILED(status))
                    {
                        SYSTEM_1Print("MSGQ_get () failed. Status = [0x%x]\n", status);
                    }
        #if defined (VERIFY_DATA)
                    /* Verify correctness of data received. */
                    if (DSP_SUCCEEDED(status))
                    {
                        status = helloDSP_VerifyData(msg, sequenceNumber);
                        if (DSP_FAILED(status))
                        {
                            MSGQ_free((MsgqMsg) msg);
                        }
                    }
        #endif

                    if (msg->command == 0x02)
                    {
                        SYSTEM_1Print("Message received: %s\n", (Uint32) msg->arg1);
                        if(count == 1)
                        {
                            for (j = 0; j < SIZE/2; j++)
                            {
                                for (k = 0; k < SIZE; k++)
                                {
                                    printf("%d ", msg->mat[j+SIZE/2+step_select][k]);
                                }
                                printf("\n");
                            }
                        } 
                        //printf("SIZE %d\n", SIZE);
                    }

                }

                printf("%d\n", count);
                count++;
            }//while ends
        }

#if defined (PROFILE)
        if (DSP_SUCCEEDED(status))
        {
            SYSTEM_GetEndTime();
            SYSTEM_GetProfileInfo(numIterations);
        }
#endif

        SYSTEM_0Print("Leaving helloDSP_Execute ()\n");

        return status;
    }