This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Ouestion about read data file from host

Hi all,
I have question about reading file from hard disk to host.
I use TMDSEVM with Blackhawk XDS560v2 USB Mezzanine Emulator.
I have data file to text format. Size of file is 2000 Kbytes. I am reading this file as used to C..
Time to reading this file is very long - 205 sec. How can I reduce time reading?

Best regards,
Oleg

  • Hi,
    How you are reading the file ?
    Using basic fread() API ?
  • Hi Titus,
    below is my text
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include "small_stable.h"
    #include "deployment.h"

    #pragma DATA_ALIGN(bunch_spectr, CACHE_L1D_LINESIZE);
    #pragma DATA_SECTION(bunch_spectr, ".sharedDDR");
    f32 bunch_spectr[1024][128];
    float complex_sweep[256];

    FILE * appropriate_file();
    int _read_cur_complex_sweep(FILE * pfile, int range_sweep);
    int Petrov_bunch_r4();
    int main(void) {

    int res;
    clock_t ttt;
    ttt = clock();

    res = Petrov_bunch_r4();
    if (res == 1) {
    printf("\nRead Bunch completed");
    ttt = clock() - ttt;
    printf("\n time read = %e", ((float)ttt)/CLOCKS_PER_SEC);
    }

    return 1;
    }

    FILE * appropriate_file() {
    FILE * pfile = NULL;
    pfile = fopen("..C:/Users/Borovikov_O/RavData/PetrovData/test_array_2_s.DAT", "r");
    return pfile;
    }

    int _read_cur_complex_sweep(FILE * pfile, int range_sweep) {
    float value = 0.;
    char _buf[75];
    int cur_range = 0;
    memset(complex_sweep, 0, sizeof(complex_sweep));
    while(fgets(_buf, sizeof(_buf), pfile)) {
    _buf[strlen(_buf)-1] = '\0';
    value = atof(_buf);
    complex_sweep[cur_range] = value;
    cur_range += 1;
    if(cur_range >= range_sweep)
    return 1;
    }
    return -1;
    }
    int Petrov_bunch_r4(){
    FILE * pfile = appropriate_file();
    if(pfile == NULL) {
    printf("\nDon't open signal file");
    return -1;
    }
    int num_sweep = 0;
    while(num_sweep < FOURIER_PARAM) {
    if(_read_cur_complex_sweep(pfile, NUMBER_OF_COUNT*2) < 0) {
    printf("\nError to read signal file");
    fclose(pfile);
    return -1;
    }
    num_sweep += 1;
    }
    printf("\nFile read successful");
    fclose(pfile);
    return 1;
    }