Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
azure-cloud-mining-script
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
azure-cloud-mining-script
Commits
e6177f1c
There was an error fetching the commit references. Please try again later.
Commit
e6177f1c
authored
6 years ago
by
SChernykh
Committed by
psychocrypt
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
optimize cn-heavy div
x-ref:
https://github.com/xmrig/xmrig-amd/pull/192
parent
28ef8e3d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xmrstak/backend/amd/amd_gpu/opencl/fast_div_heavy.cl
+12
-37
12 additions, 37 deletions
xmrstak/backend/amd/amd_gpu/opencl/fast_div_heavy.cl
with
12 additions
and
37 deletions
xmrstak/backend/amd/amd_gpu/opencl/fast_div_heavy.cl
+
12
−
37
View file @
e6177f1c
...
...
@@ -2,49 +2,24 @@ R"===(
#ifndef FAST_DIV_HEAVY_CL
#define FAST_DIV_HEAVY_CL
inline
u
long
get_reciprocal_heavy(u
int
a
)
inline long
fast_div_heavy(long _a,
int
_b
)
{
const uint shift = clz(a);
a <<= shift;
const float a_hi = as_float((a >> 8) + 1 + ((126U + 31U) << 23));
const float a_lo = convert_float_rte(as_int(a & 0xFF) - 256);
const float r = native_recip(a_hi);
const uint tmp0 = as_uint(r);
const uint tmp1 = tmp0 + ((shift + 2 + 64U) << 23);
const float r_scaled = as_float(tmp1);
const float h = fma(a_lo, r, fma(a_hi, r, -1.0f));
const float r_scaled_hi = as_float(tmp1 & ~4095U);
const float h_hi = as_float(as_uint(h) & ~4095U);
long a = abs(_a);
int b = abs(_b);
const
float r
_scaled_lo = r_scaled - r_scaled_hi
;
const float h_lo = h - h_hi
;
float r
cp = native_recip(convert_float_rte(b))
;
float rcp2 = as_float(as_uint(rcp) + (32U << 23))
;
const float x1 = h_hi * r_scaled_hi
;
const float x2 = h_lo * r_scaled + h_hi * r_scaled_lo
;
ulong q1 = convert_ulong_rte(convert_float_rte(as_int2(a).s1) * rcp2)
;
a -= q1 * as_uint(b)
;
const long h1 = convert_long_rte(x1);
const int h2 = convert_int_rtp(x2) - convert_int_rtn(h * (x1 + x2));
const ulong result = tmp0 & 0xFFFFFF;
return (result << (shift + 9)) - ((h1 + h2) >> 2);
}
inline long fast_div_heavy(long _a, int _b)
{
const ulong a = abs(_a);
const uint b = abs(_b);
ulong q = mul_hi(a, get_reciprocal_heavy(b));
long q2 = convert_long_rte(convert_float_rtn(a) * rcp);
int a2 = as_int2(a).s0 - as_int2(q2).s0 * b;
const long tmp = a - q * b;
const int overshoot = (tmp < 0) ? 1 : 0;
const int undershoot = (tmp >= b) ? 1 : 0;
q += undershoot - overshoot;
int q3 = convert_int_rte(convert_float_rte(a2) * rcp);
q3 += (a2 - q3 * b) >> 31;
const long q = q1 + q2 + q3;
return ((as_int2(_a).s1 ^ _b) < 0) ? -q : q;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment