Skip to content

Commit

Permalink
Fix ia64 speculative loads
Browse files Browse the repository at this point in the history
Speculative loads do not generate any faults, as intendet. Instead
you should check the valid bit of your speculative load.

But speculative loads are great to shedule your loop. If you have
another loop iteration, your load of the next iteration data was
"good", if not, who cares. No need to check any bits.

The problem is: Speculative loads do not generate _any_ faults
(Wait, we had that...). So they also do not generate any valid
page faults to signal the OS action is required because a page
is swapped out or a mmaped file page needs to be fetched.

So fetch the buffer end of this outer loop iteration at each
outer loop start.

And maybe we even have to be more agressive about that...
  • Loading branch information
kaffeemonster committed May 27, 2011
1 parent b6d4459 commit d0a3536
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions ia64/adler32.c
Expand Up @@ -222,16 +222,25 @@ local noinline uLong adler32_vec(adler, buf, len)
"(p6) mov unpck_15 = inner_loop_count\n\t"
"(p7) mov unpck_15 = k;;\n\t"

"mov unpck_16 = buf_ptr_1\n\t"
"and unpck_14 = -16, unpck_15\n\t"
"and loop_rem = 63, unpck_15\n\t"
"shr.u unpck_13 = unpck_15, 6;;\n\t"
"and loop_rem = 63, unpck_15;;\n\t"

"cmp4.eq p7,p6 = 0, unpck_13;;\n\t"
"sub k = k, unpck_14\n\t"
"mov vs2_wsum_hh = r0\n\t"
"shr.u unpck_13 = unpck_15, 6\n\t"
"add unpck_16 = unpck_15, unpck_16;;\n\t"

"nop.m 0\n\t"
"nop.i 0\n\t"
"cmp4.eq p7,p6 = 0, unpck_13\n\t"
"sub k = k, unpck_14\n\t"
"add unpck_16 = -33, unpck_16;;\n\t"

/* prefetch end of buffer for this iterration,
* to make sure OS sees possible page faults so
* OS can swap page in, because speculative
* loads will not.
*/
"lfetch.fault [unpck_16]\n\t"
"nop.i 1\n\t"
"(p7) br.cond.dpnt.few 5f\n\t"

"ld8 input8_3 = [buf_ptr_3], 32\n\t"
Expand Down

0 comments on commit d0a3536

Please sign in to comment.