Ejemplo n.º 1
0
    /** ============================================================================
     *  @func   helloDSP_Main
     *
     *  @desc   Entry point for the application
     *
     *  @modif  None
     *  ============================================================================
     */
    NORMAL_API Void helloDSP_Main(IN Char8* dspExecutable, IN Char8* strNumIterations, IN Char8* strProcessorId)
    {
        DSP_STATUS status = DSP_SOK;
        Uint32 numIterations = 0;
        Uint8 processorId = 0;

        SYSTEM_0Print ("========== Sample Application : helloDSP ==========\n");

        if ((dspExecutable != NULL) && (strNumIterations != NULL))
        {
            numIterations = SYSTEM_Atoi(strNumIterations);

            if (numIterations > 0xFFFF)
            {
                status = DSP_EINVALIDARG;
                SYSTEM_1Print("ERROR! Invalid arguments specified for helloDSP application.\n Max iterations = %d\n", 0xFFFF);
            }
            else
            {
                processorId = SYSTEM_Atoi(strProcessorId);

                if (processorId >= MAX_DSPS)
                {
                    SYSTEM_1Print("== Error: Invalid processor id %d specified ==\n", processorId);
                    status = DSP_EFAIL;
                }
                /* Specify the dsp executable file name for message creation phase. */
                if (DSP_SUCCEEDED(status))
                {
                    status = helloDSP_Create(dspExecutable, strNumIterations, processorId);

                    /* Execute the message execute phase. */
                    if (DSP_SUCCEEDED(status))
                    {
                        status = helloDSP_Execute(numIterations, processorId);
                    }

                    /* Perform cleanup operation. */
                    helloDSP_Delete(processorId);
                }
            }
        }
        else
        {
            status = DSP_EINVALIDARG;
            SYSTEM_0Print("ERROR! Invalid arguments specified for helloDSP application\n");
        }
        SYSTEM_0Print ("====================================================\n");
    }
Ejemplo n.º 2
0
    /** ============================================================================
     *  @func   helloDSP_Delete
     *
     *  @desc   This function releases resources allocated earlier by call to
     *          helloDSP_Create ().
     *          During cleanup, the allocated resources are being freed
     *          unconditionally. Actual applications may require stricter check
     *          against return values for robustness.
     *
     *  @modif  None
     *  ============================================================================
     */
    NORMAL_API Void helloDSP_Delete(Uint8 processorId)
    {
        DSP_STATUS status = DSP_SOK;
        DSP_STATUS tmpStatus = DSP_SOK;

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

        /* Release the remote message queue */
        status = MSGQ_release(SampleDspMsgq);
        if (DSP_FAILED(status))
        {
            SYSTEM_1Print("MSGQ_release () failed. Status = [0x%x]\n", status);
        }

        /* Close the remote transport */
        tmpStatus = MSGQ_transportClose(processorId);
        if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
        {
            status = tmpStatus;
            SYSTEM_1Print("MSGQ_transportClose () failed. Status = [0x%x]\n", status);
        }

        /* Stop execution on DSP. */
        tmpStatus = PROC_stop(processorId);
        if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
        {
            status = tmpStatus;
            SYSTEM_1Print("PROC_stop () failed. Status = [0x%x]\n", status);
        }

        /* Reset the error handler before deleting the MSGQ that receives */
        /* the error messages.                                            */
        tmpStatus = MSGQ_setErrorHandler(MSGQ_INVALIDMSGQ, MSGQ_INVALIDMSGQ);

        if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
        {
            status = tmpStatus;
            SYSTEM_1Print("MSGQ_setErrorHandler () failed. Status = [0x%x]\n", status);
        }

        /* Close the GPP's message queue */
        tmpStatus = MSGQ_close(SampleGppMsgq);
        if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
        {
            status = tmpStatus;
            SYSTEM_1Print("MSGQ_close () failed. Status = [0x%x]\n", status);
        }

        /* Close the pool */
        tmpStatus = POOL_close(POOL_makePoolId(processorId, SAMPLE_POOL_ID));
        if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
        {
            status = tmpStatus;
            SYSTEM_1Print("POOL_close () failed. Status = [0x%x]\n", status);
        }

        /* Detach from the processor */
        tmpStatus = PROC_detach(processorId);
        if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
        {
            status = tmpStatus;
            SYSTEM_1Print("PROC_detach () failed. Status = [0x%x]\n", status);
        }

        /* Destroy the PROC object. */
        tmpStatus = PROC_destroy();
        if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
        {
            status = tmpStatus;
            SYSTEM_1Print("PROC_destroy () failed. Status = [0x%x]\n", status);
        }

        SYSTEM_0Print("Leaving helloDSP_Delete ()\n");
    }
Ejemplo n.º 3
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;
    }
Ejemplo n.º 4
0
    /** ============================================================================
     *  @func   helloDSP_Create
     *
     *  @desc   This function allocates and initializes resources used by
     *          this application.
     *
     *  @modif  helloDSP_InpBufs , helloDSP_OutBufs
     *  ============================================================================
     */
    NORMAL_API DSP_STATUS helloDSP_Create(IN Char8* dspExecutable, IN Char8* strNumIterations, IN Uint8 processorId)
    {
        DSP_STATUS status = DSP_SOK;
        Uint32 numArgs = NUM_ARGS;
        MSGQ_LocateAttrs syncLocateAttrs;
        Char8* args[NUM_ARGS];

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

        /* Create and initialize the proc object. */
        status = PROC_setup(NULL);

        /* Attach the Dsp with which the transfers have to be done. */
        if (DSP_SUCCEEDED(status))
        {
            status = PROC_attach(processorId, NULL);
            if (DSP_FAILED(status))
            {
                SYSTEM_1Print("PROC_attach () failed. Status = [0x%x]\n", status);
            }
        }

        /* Open the pool. */
        if (DSP_SUCCEEDED(status))
        {
            status = POOL_open(POOL_makePoolId(processorId, SAMPLE_POOL_ID), &SamplePoolAttrs);
            if (DSP_FAILED(status))
            {
                SYSTEM_1Print("POOL_open () failed. Status = [0x%x]\n", status);
            }
        }
        else
        {
            SYSTEM_1Print("PROC_setup () failed. Status = [0x%x]\n", status);
        }

        /* Open the GPP's message queue */
        if (DSP_SUCCEEDED(status))
        {
            status = MSGQ_open(SampleGppMsgqName, &SampleGppMsgq, NULL);
            if (DSP_FAILED(status))
            {
                SYSTEM_1Print("MSGQ_open () failed. Status = [0x%x]\n", status);
            }
        }

        /* Set the message queue that will receive any async. errors */
        if (DSP_SUCCEEDED(status))
        {
            status = MSGQ_setErrorHandler(SampleGppMsgq, POOL_makePoolId(processorId, SAMPLE_POOL_ID));
            if (DSP_FAILED(status))
            {
                SYSTEM_1Print("MSGQ_setErrorHandler () failed. Status = [0x%x]\n", status);
            }
        }

        /* Load the executable on the DSP. */
        if (DSP_SUCCEEDED(status))
        {
            args [0] = strNumIterations;
            {
                status = PROC_load(processorId, dspExecutable, numArgs, args);
            }
            if (DSP_FAILED(status))
            {
                SYSTEM_1Print("PROC_load () failed. Status = [0x%x]\n", status);
            }
        }

        /* Start execution on DSP. */
        if (DSP_SUCCEEDED(status))
        {
            status = PROC_start(processorId);
            if (DSP_FAILED(status))
            {
                SYSTEM_1Print("PROC_start () failed. Status = [0x%x]\n", status);
            }
        }

        /* Open the remote transport. */
        if (DSP_SUCCEEDED(status))
        {
            mqtAttrs.poolId = POOL_makePoolId(processorId, SAMPLE_POOL_ID);
            status = MSGQ_transportOpen(processorId, &mqtAttrs);
            if (DSP_FAILED(status))
            {
                SYSTEM_1Print("MSGQ_transportOpen () failed. Status = [0x%x]\n", status);
            }
        }

        /* Locate the DSP's message queue */
        /* At this point the DSP must open a message queue named "DSPMSGQ" */
        if (DSP_SUCCEEDED(status))
        {
            syncLocateAttrs.timeout = WAIT_FOREVER;
            status = DSP_ENOTFOUND;
            SYSTEM_2Sprint(dspMsgqName, "%s%d", (Uint32) SampleDspMsgqName, processorId);
            while ((status == DSP_ENOTFOUND) || (status == DSP_ENOTREADY))
            {
                status = MSGQ_locate(dspMsgqName, &SampleDspMsgq, &syncLocateAttrs);
                if ((status == DSP_ENOTFOUND) || (status == DSP_ENOTREADY))
                {
                    SYSTEM_Sleep(100000);
                }
                else if (DSP_FAILED(status))
                {
                    SYSTEM_1Print("MSGQ_locate () failed. Status = [0x%x]\n", status);
                }
            }
        }

        SYSTEM_0Print("Leaving helloDSP_Create ()\n");
        return status;
    }
Ejemplo n.º 5
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;
    }
Ejemplo n.º 6
0
/** ============================================================================
 *  @func   helloDSP_Main
 *
 *  @desc   Entry point for the application
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API Void helloDSP_Main(IN Char8* dspExecutable, IN Char8* strNumIterations, IN Char8* strProcessorId)
{
	DSP_STATUS status = DSP_SOK;
	//Uint32 numIterations = 0;
	Uint8 processorId = 0;

	// Define the mxsize to define the matrices
	Uint32 mxSize = SYSTEM_Atoi(strNumIterations);

	Uint32 matrixA[mxSize * mxSize];
	Uint32 matrixB[mxSize * mxSize];
	Uint32 matrixC[mxSize * mxSize];

	//Uint8 numMessages = ((2 * mxSize * mxSize - 1) / ARG_SIZE) + 2;

	// WARNING strNumIterations is the matrixSize
	SYSTEM_0Print ("========== Starting the GPP Code ==========\n");

	if ((dspExecutable != NULL) && (strNumIterations != NULL))
	{
		// WARNING This is also the matrix size
		mxSize = SYSTEM_Atoi(strNumIterations);
		// TODO possibly alter the maximum matrix size afterwards
		if (mxSize > 128)
		{
			status = DSP_EINVALIDARG;
			SYSTEM_1Print("ERROR! Invalid arguments specified for helloDSP application.\n Max matrixsize = %d\n", 128);
		}
		else
		{
			processorId = SYSTEM_Atoi(strProcessorId);

			if (processorId >= MAX_DSPS)
			{
				SYSTEM_1Print("== Error: Invalid processor id %d specified ==\n", processorId);
				status = DSP_EFAIL;
			}
			/* Specify the dsp executable file name for message creation phase. */
			if (DSP_SUCCEEDED(status))
			{
				// WARNING strNumIterations is still the matrixSize
				status = helloDSP_Create(dspExecutable, strNumIterations, processorId);

				/* Execute the message execute phase. */
				if (DSP_SUCCEEDED(status))
				{
					status = helloDSP_Execute(mxSize, processorId, (Uint32*) matrixA, (Uint32*) matrixB, (Uint32*) matrixC);
				}

				/* Perform cleanup operation. */
				helloDSP_Delete(processorId);
			}
		}
	}
	else
	{
		status = DSP_EINVALIDARG;
		SYSTEM_0Print("ERROR! Invalid arguments specified for helloDSP application\n");
	}
	SYSTEM_0Print ("====================================================\n");
}
Ejemplo n.º 7
0
// WARNING mxSize is the matrixSize here
NORMAL_API DSP_STATUS helloDSP_Execute(IN Uint32 mxSize, Uint8 processorId, Uint32* matrixA, Uint32* matrixB, Uint32* matrixC)
{
	DSP_STATUS status = DSP_SOK;
	Uint16 sequenceNumber = 0;
	Uint16 msgId = 0;
	Uint32 i, j;
	ControlMsg *msg;
	Uint8 flag = 0;

	Uint32 matrixD[mxSize * mxSize];

	Uint32 numElements, numMessages, elementCount, messageCount;
	Uint32 sizeElements, numProdMessages, matrixCount, prodElements;
	Char8 ascii_string[STRING_SIZE + 1];
	Char8 null_string[STRING_SIZE + 1] = {'\0','\0','\0','\0','\0','\0'};

	myStrcpy(ascii_string, null_string);

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

	// Wait for the first DSP is awake message
	status = MSGQ_get(SampleGppMsgq, WAIT_FOREVER, (MsgqMsg *) &msg);
	if (DSP_FAILED(status))
	{
		SYSTEM_1Print("MSGQ_get () failed. Status = [0x%x]\n", status);
	}

	// TODO possibly verify the data?

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

	SYSTEM_0Print("Generated matrices:\n");
	// Generate the matrices after the DSPLink is established
	matrixGen(mxSize, matrixA, matrixB);

	// Have to translate the Int32 matrix elements to string elements
	// or the communication protocol
	prodElements = (mxSize * mxSize);
	numElements = (mxSize * mxSize * 2);
	sizeElements = numElements * STRING_SIZE;
	numMessages = ((sizeElements - 1) / ARG_MSG) + 1;
	numProdMessages = (((sizeElements / 2) - 1) / ARG_MSG) + 1;

	//SYSTEM_2Print("NumElements: %d, NumMessages: %d\n", numElements, numMessages);

	// WARNING Sending 5 Char8 each for loop
	// Start sending the matrices to the DSP which is not waiting
	for (messageCount = 0, elementCount = 0; messageCount < numMessages; messageCount++)
	{
		// First send a message, then receive
		//for ( ; (((elementCount - (messageCount * ARG_MSG)) * STRING_SIZE) < ARG_MSG ) && elementCount < numElements; elementCount++)

#if defined (PROFILE)
		SYSTEM_GetStartTimeDspEnc();
#endif
		for (; (elementCount - (messageCount * ARG_MSG)) < ARG_MSG && elementCount < numElements; elementCount++)
		{
			//SYSTEM_0Print("Putting element in a message\n");
			//itoa
			if(elementCount < prodElements)
			{
				SYSTEM_itoa(matrixA[elementCount], ascii_string, 10);
				//SYSTEM_1Print("Looping through string: %s in MatrixA\n", (Uint32) ascii_string);
			}
			else
			{
				SYSTEM_itoa(matrixB[elementCount - prodElements], ascii_string, 10);
				//SYSTEM_1Print("Looping through string: %s in MatrixB\n", (Uint32) ascii_string);
			}
			//SYSTEM_0Print("After SYSTEM_itoa\n");

			// loop through characters of the string
			for (i = 0; i < STRING_SIZE; i++)
			{
				msg->arg1[((elementCount * STRING_SIZE) - (messageCount * ARG_MSG)) + i] = ascii_string[i];
				//SYSTEM_sprintf(msg->arg1[(elementCount - (messageCount * ARG_MSG)) + i] = ascii_string[i];
			}
			// clean the string
			myStrcpy(ascii_string, null_string);
		}

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

		//SYSTEM_0Print("Filled a single message\n");

		// After filling a single message, should send it to the DSP and wait for a reply 
		// unless it is the last one
		if (DSP_SUCCEEDED(status))
		{
			//SYSTEM_0Print("DSP succeeded after filling\n");

#if defined (PROFILE)
			SYSTEM_GetStartTimeDspMes();
#endif
			msgId = MSGQ_getMsgId(msg);
			MSGQ_setMsgId(msg, msgId);
			// TODO set the command flag of the msg to distinguish
			status = MSGQ_put(SampleDspMsgq, (MsgqMsg) msg);
			if (DSP_FAILED(status))
			{
				MSGQ_free((MsgqMsg) msg);
				SYSTEM_1Print("MSGQ_put () failed. Status = [0x%x]\n", status);
			}
#if defined (PROFILE)
			else {
				SYSTEM_GetEndTimeDspMes();
				SYSTEM_GetStartTimeDspCalc();
			}
#endif
		}

		//SYSTEM_0Print("Message send\n");

		sequenceNumber++;
		// Make sure that the sequenceNumber stays within the permitted
		// range for applications. 
		if (sequenceNumber == MSGQ_INTERNALIDSSTART)
		{
			//SYSTEM_0Print("Something with sequences\n");
			sequenceNumber = 0;
		}
		// If it is the last message, don't wait for an acknowledge
		if (messageCount + 1 < numMessages)
		{
			// Wait for a response of the DSP before sending a reply
			status = MSGQ_get(SampleGppMsgq, WAIT_FOREVER, (MsgqMsg *) &msg);
			if (DSP_FAILED(status))
			{
				SYSTEM_1Print("MSGQ_get () failed. Status = [0x%x]\n", status);
			}

			//SYSTEM_1Print("Received: %s\n", (Uint32) msg->arg1);
		}
	}

	//SYSTEM_0Print("Sending completed..\n");

	// TODO start receiving the product matrix 
	// WARNING wait and acknowledge except for last loop
	for (messageCount = 0, elementCount = 0, matrixCount = 0; messageCount < numProdMessages; messageCount++)
	{
		status = MSGQ_get(SampleGppMsgq, WAIT_FOREVER, (MsgqMsg *) &msg);

		if (messageCount == 0) {
#if defined (PROFILE)
			SYSTEM_GetEndTimeDspCalc();
#endif
			SYSTEM_0Print("\nProduct matrix on DSP:\n");
		}
		//SYSTEM_1Print("Message received: %s\n", (Uint32) msg->arg1);
		if (DSP_FAILED(status))
		{
			SYSTEM_1Print("MSGQ_get () failed. Status = [0x%x]\n", status);
		}
		// Put the received message in the matrixC
		for (; matrixCount < prodElements && (elementCount - (messageCount * ARG_MSG)) < ARG_MSG && elementCount < (prodElements * STRING_SIZE); matrixCount++, elementCount += STRING_SIZE)
		{
			// atoi
			for (i = 0; i < STRING_SIZE; i++)
			{
				ascii_string[i] = msg->arg1[elementCount + i];
			}
			ascii_string[5] = '\0';
			/*
			 if (matrixCount >= 72)
			 {
			 SYSTEM_1Print("Ascii string received: %s\n", ascii_string);
			 }
			 */
			// Put it in the matrixC
			matrixC[matrixCount] = atoi(ascii_string);
			// print the string
			if (matrixCount % mxSize == 0)
			{
				SYSTEM_0Print("\n");
			}
			SYSTEM_1Print("%d ", matrixC[matrixCount]);

			// Clean the string
			myStrcpy(ascii_string, null_string);
		}

		// If this is not the last message, send an acknowledge
		if (messageCount + 1 < numProdMessages)
		{
			// 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;
			}
		}
	}

	SYSTEM_0Print("\n");

	MSGQ_free((MsgqMsg) msg);
	//SYSTEM_0Print("After freeing the message..\n");

	SYSTEM_0Print("\nProduct matrix on GPP:\n");

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

	matMult(matrixA, matrixB, matrixD, mxSize);

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

	// compare the matrices
	for(i=0; i<mxSize; i++)
	{
		for(j=0; j<mxSize; j++)
		{
			if(matrixC[i * mxSize + j] != matrixD[i * mxSize + j])
			{
				SYSTEM_2Print("Matrices are not equal row: %d, column: %d\n", i, j);
				flag = 1;
				break;
			}
		}
	}
	if (flag == 0)
	{
		SYSTEM_0Print("\nMatrix products are equal\n");
	}

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

#if defined (PROFILE)
	if (DSP_SUCCEEDED(status))
	{
		SYSTEM_GetProfileInfoGpp();
		SYSTEM_GetProfileInfoDsp(numMessages); //is numProdMessages interesting?
	}
#endif

	return status;
}