From fb4e5b75e9e6601e645b72689f5c28beb68f6657 Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Fri, 10 Sep 2010 14:33:56 -0400 Subject: [PATCH] Add support for writing float literals in store_per_thread --- cuburnlib/ptx.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cuburnlib/ptx.py b/cuburnlib/ptx.py index f25c47e..5171a32 100644 --- a/cuburnlib/ptx.py +++ b/cuburnlib/ptx.py @@ -673,6 +673,10 @@ class _PTXStdLib(PTXFragment): op.mov.u32(spt_base, base) self.get_gtid(spt_offset) op.mad.lo.u32(spt_base, spt_offset, 4, spt_base) + if isinstance(val, float): + # Turn a constant float into the big-endian PTX binary float + # representation, 0fXXXXXXXX (where XX is hex byte) + val = '0f%x%x%x%x' % reversed(map(ord, struct.pack('f', val))) op.st.b32(addr(spt_base), val) @ptx_func