summaryrefslogtreecommitdiff
path: root/sc/source/core/opencl
diff options
context:
space:
mode:
authoryangzhang <yangzhang@multicorewareinc.com>2013-12-24 13:14:56 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-12-30 15:05:25 -0600
commit60ae598d537c14283109e1c6de22ec43a0147bcf (patch)
treedc8022cd76c43f2f3d3eb2927325f61ce94ca036 /sc/source/core/opencl
parentb8bbde02a51a952ee268ed818d6201d6b5c57ec6 (diff)
GPU Calc: Optimized RANDOM
AMLOEXT-260 Change-Id: I3fd0a857a476a34401cfa522f828bed3bb79c9e2 Signed-off-by: haochen <haochen@multicorewareinc.com> Signed-off-by: Wei Wei <weiwei@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc/source/core/opencl')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx27
1 files changed, 22 insertions, 5 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 9c16ab77f13b..6045b251c032 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -291,10 +291,7 @@ public:
}
virtual void GenDeclRef(std::stringstream &ss) const
{
- double d;
- srand((unsigned)time(NULL));
- d=((double)rand())/RAND_MAX;
- ss << d;
+ ss << mSymName;
}
virtual void GenSlidingWindowDecl(std::stringstream &ss) const
{
@@ -302,7 +299,27 @@ public:
}
virtual std::string GenSlidingWindowDeclRef(bool=false) const
{
- return mSymName;
+ return mSymName + "_Random()";
+ }
+ void GenSlidingWindowFunction(std::stringstream &ss)
+ {
+ ss << "\ndouble " << mSymName;
+ ss << "_Random ()\n{\n";
+ ss << " int i, gid0=get_global_id(0);;\n";
+ ss << " double tmp = 0;\n";
+ ss << " double M = 2147483647;\n";
+ ss << " double Lamda = 32719;\n";
+ ss << " double f;\n";
+ ss << " f = gid0 + 1;\n";
+ ss << " int k;\n";
+ ss << " for(i = 1;i <= 100; ++i){\n";
+ ss << " f = Lamda * f;\n";
+ ss << " k = (int)(f * pow(M,-1.0));\n";
+ ss << " f = f - M * k;\n";
+ ss << " }\n";
+ ss << " tmp = f * pow(M,-1.0);\n";
+ ss << " return tmp;\n";
+ ss << "}";
}
virtual size_t GetWindowSize(void) const
{