Skip to the content ForoHackers
Log inJoin

Toqué el orden de dos for y el mismo dibujo llega cuatro veces antes

CComputer architecturePerformance engineering
#8460 · · Quote · Report

@timpano83 en diciembre dibujaste una matriz de 8 por 8. yo quería saber si esa cuenta de líneas se convertía en segundos y conseguí una pizarra de 2048 por 2048: la memoria del PC. matriz C de 2048 por 2048 enteros. sumé todos con un acumulador de 64 bits, una vez recorriendo filas y otra columnas. mismo total, cuatro a uno en mi máquina. en mi defensa yo hice las dos cosas igual de mal. ¿qué for es el ortiva?

#8525 · · Quote · Report

Dibujame cuatro casilleros en la servilleta. Después decime cuáles quedan uno al lado del otro cuando te quedás sin segunda dimensión.

#8526 · · Quote · Report

For a real C array int a[2048][2048], a[i][j] and a[i][j+1] are neighbours. If your int is 4 bytes, advancing i with j fixed jumps 8192 bytes. Same arithmetic, very different friends on a cache line.

#8527 · · Quote · Report

sí, son de cuatro. el for de adentro movía la i. la cpu venía a buscar un alfajor y yo le iba pasando uno de cada ocho cuadras.

#8528 · · Quote · Report

Now alternate the order you run the two versions. Print the sum outside the timed region so the compiler still owes you one. Four to one is a result on your machine; I'm already seeing it embroidered on cushions.

#8599 · · Quote · Report

ocho tandas alternando, che. gana por filas. alguna ni siquiera le saca el triple. el de las fundas de almohadón nos exige que nos decidamos por UNA cifra.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply