Kaydet (Commit) 60ae598d authored tarafından yangzhang's avatar yangzhang Kaydeden (comit) I-Jui (Ray) Sung

GPU Calc: Optimized RANDOM

AMLOEXT-260

Change-Id: I3fd0a857a476a34401cfa522f828bed3bb79c9e2
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
Signed-off-by: 's avatarWei Wei <weiwei@multicorewareinc.com>
Signed-off-by: 's avatarI-Jui (Ray) Sung <ray@multicorewareinc.com>
üst b8bbde02
...@@ -291,10 +291,7 @@ public: ...@@ -291,10 +291,7 @@ public:
} }
virtual void GenDeclRef(std::stringstream &ss) const virtual void GenDeclRef(std::stringstream &ss) const
{ {
double d; ss << mSymName;
srand((unsigned)time(NULL));
d=((double)rand())/RAND_MAX;
ss << d;
} }
virtual void GenSlidingWindowDecl(std::stringstream &ss) const virtual void GenSlidingWindowDecl(std::stringstream &ss) const
{ {
...@@ -302,7 +299,27 @@ public: ...@@ -302,7 +299,27 @@ public:
} }
virtual std::string GenSlidingWindowDeclRef(bool=false) const 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 virtual size_t GetWindowSize(void) const
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment