Question: using C language I've begun a C function that intends to bitwise xor two memory buffers together and write the result to a third buffer

using C language

I've begun a C function that intends to bitwise xor two memory buffers together and write the result to a third buffer (ie, the i-th byte of output is the bitwise xor of the i-th bytes of the two inputs). Finish the function using SSE to accellerate the process. If the buffer is not a multiple of 16 bytes long, you will need to complete the xoring in a second loop that xors one byte at a time. Use SSE instrinsics for all SSE loads, stores, and manipulations.

You do not have to use the code I've written if you'd like to handle it with a different setup, but you must keep the function header as-is

using C language I've begun a C function that intends to bitwise

1 #include 2 #include 3 4 /* Bitwise xors sz bytes of memory beginning at src1 and src2 */ 5 /* writing the results to memory beginning at dst. 6 - void xor_sse(void *dst, void *srci, void *src2, int sz) { 7 uint8_t *d (uint8_t *)dst; // d has same address as dst 8 uint8_t *s1 (uint8_t *)src1; // s1 has same address as src1 9 uint8_t *s2 (uint8_t *)src2; // s2 has same address as src2 10 11 // Write loop that uses SSE as far as possible 12 13 // Write loop that finishes any leftover without SSE 14 } 1 #include 2 #include 3 4 /* Bitwise xors sz bytes of memory beginning at src1 and src2 */ 5 /* writing the results to memory beginning at dst. 6 - void xor_sse(void *dst, void *srci, void *src2, int sz) { 7 uint8_t *d (uint8_t *)dst; // d has same address as dst 8 uint8_t *s1 (uint8_t *)src1; // s1 has same address as src1 9 uint8_t *s2 (uint8_t *)src2; // s2 has same address as src2 10 11 // Write loop that uses SSE as far as possible 12 13 // Write loop that finishes any leftover without SSE 14 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!