Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating a matrix in tta_stream_v1.in but not able to write the matrix on tta_stream_v1.out #252

Open
Rhrifateee opened this issue Dec 19, 2023 · 1 comment

Comments

@Rhrifateee
Copy link

Hi, I can generate a matrix of 10x20 dimension of random integers in tta_stream_v1.in, the FU has been added from "Add from HDB".
main_architecture
stream_in_HDB
stream_out_HDB
random_h

The code to generate 10x20 matrix in tta_stream_v1.in is (this file is named as: "random.c")

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#include "random.h"
void generateRandomMatrix(int rows, int cols, FILE *file) {

for (int i = 0; i < rows; ++i) {

    for (int j = 0; j < cols; ++j) {

        //fprintf(file, "%0.4f", ((double)rand() / (double)RAND_MAX));

        

         fprintf(file, "%d ", rand() % 100);

    }

    fprintf(file, "\n");

}

}

int main() {

//int hiddenSize1=10;

//int inputSize=20;

srand(time(NULL)); 

FILE *outputFile = fopen("tta_stream_v1.in", "w");



if (outputFile == NULL) {

    fprintf(stderr, "Error opening the file.\n");

    return 1;

}



// Generate a random 10x20 matrix and write it to the file

generateRandomMatrix(hiddenSize1, inputSize, outputFile);



fclose(outputFile);

printf("Random numbers have been written to 'tta_stream_v1.in'.\n");



return 0;

}

The tta_stream_v1.in writes the matrix from the above code as follows:

tta_stream_v1_in

Now I want to read the matrix from tta_stream_v1.in and write it to tta_stream_v1.out by writing another code random_main.c. The code is given below:
#include <tceops.h>

//#include <time.h>

#include <stdlib.h>

//#include <math.h>

#include <stdio.h>

#include "random.h"
int main()

{

int X[hiddenSize1][inputSize];

int test[hiddenSize1][inputSize]={{0},{0}};

//int test = 0;

for (int i = 0; i < hiddenSize1; i++) 

{

    for (int j = 0; j < inputSize; j++) 

    {

    _TCE_STREAM_IN_V1(0,test[i][j]);

    //_TCE_STREAM_IN_V1(0,test);

       X[i][j] = test[i][j];

       //X[i][j] = test;

       _TCE_STREAM_OUT_V1(X[i][j]);

       }

  }

return 0;

}

The output in tta_stream_v1.out is:
image

What modification should I do in my random_main.c code to write the matrix in tta_stream_v1.out exactly as it is in tta_stream_v1.in?

@pjaaskel
Copy link
Contributor

How do the STREAM_IN/OUT_* operation definitions look like? These are not OpenASIP-shipped operations so I cannot tell. Do they have the correct state flags etc. in place so the compiler doesn't reorder them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants