I have two one-megabyte buffers that I need to get the bitwise AND of. It's fine to overwrite one of the buffers to store the result. Currently I'm doing
Code:
#include <stdint.h>
#include <malloc.h>
#define BUFSIZE 0x20000
void main(int argc, char ** argv) {
uint64_t * buf1;
uint64_t * buf2;
buf1 = (uint64_t *) malloc(BUFSIZE * sizeof(uint64_t));
buf2 = (uint64_t *) malloc(BUFSIZE * sizeof(uint64_t));
// (initialization stuff)
for(int i=0; i<BUFSIZE; i++)
buf1[i] &= buf2[i];
// the above loop takes about 800 microseconds
}
I need to do this hundreds of times in a row, so I care about the speed of each iteration. Is there any faster way to do this, like a memcpy() variant with bitwise operations or something to that effect?