Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp with a copy between buffers using memcpy C
    primarykey
    data
    text
    <p>I need to copy the content of one buffer to another one in blocks of <em>n</em> bytes (<em>n</em> might vary), several times to check the cache performance.</p> <p>I use memcpy, but I'm afraid I'm not getting successful results. The block size is variable from some kbytes to Mbytes. And I have to reserve the maximum block to use (long double).</p> <p>I'm a little lost in the copy. I'm just wondering if somebody has faced this problem, and can help me with some tips or pseudo code.</p> <p>I edit the topic to include some code:</p> <pre><code>int main (int argc, char *argv[]) { FILE *fp; fp= fopen("part1.dat", "w"); struct timeval time, oldtime; float segundos, microsegundos, total; // float rendimiento; pid_t pid; struct sched_param parametros; int i, v,p; char buffer1[100024]; char buffer2[100024]; pid = getpid(); parametros.sched_priority = sched_get_priority_max(SCHED_FIFO); sched_setscheduler(pid, SCHED_FIFO, &amp;parametros); p=0; gettimeofday(&amp;oldtime, NULL); for (i=1;i&lt;65;i++) { size_t datos=i*1024; for (v=0; p&gt;i;v++) { memcpy(buffer1, buffer2, datos); p=(MAX_SIZE/i*1024); } } gettimeofday(&amp;time, NULL); segundos = (float) (time.tv_sec - oldtime.tv_sec); microsegundos = (float) (time.tv_usec - oldtime.tv_usec); total = (float) ((segundos * 1000000 + microsegundos)); // printf ("Dimension %d \t Tiempo 1: %.2f \t Fallos Metodo 1:%d \t Tiempo 2: %.2f \t Fallos Metodo 2:%d \t Multiplica: %f \t Rendimiento: %.2f\n", i, total, fallos1, total2, fallos2, iteraciones, rendimiento); // fprintf (fp, "%d \t %.3f %.3f %.3f\n", i, total, total2,rendimiento); fclose(fp); printf("Se ha creado el archivo de datos: part1.dat\n"); return(0); } </code></pre> <p>The idea is to copy from buffer1 to buffer2, in datos blocks 'p' times, in this case is supposed to be done 256000 times (i=1, datos=1024).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload