Sourceware Bugzilla – Attachment 9469 Details for
Bug 20495
x86_64 performance degradation due to AVX/SSE transition penalty
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Slower AVX example
test_sincos.c (text/x-csrc), 1.20 KB, created by
Adam Stylinski
on 2016-08-23 01:22:13 UTC
(
hide
)
Description:
Slower AVX example
Filename:
MIME Type:
Creator:
Adam Stylinski
Created:
2016-08-23 01:22:13 UTC
Size:
1.20 KB
patch
obsolete
>#define _GNU_SOURCE >#include <stdio.h> >#include <stdlib.h> >#include <math.h> > >#define TESTDIMX 128 >#define TESTDIMY 128 > >#define NUMVALS 9000 > >void testFunc(float *ain, float *bin, int *xs, > int *ys, size_t num, float *vals, > float *valsB, size_t height) >{ > for (int i = 0; i < num; ++i) { > int x = xs[i] - 1; > int y = ys[i] - 1; > int idx = height * y + x; > > float a = fabsf(vals[i]); > float s, c; > sincosf(2.0f * (float)M_PI * valsB[i], &s, &c); > > ain[idx] += a * c; > bin[idx] += a * s; > } >} > >int main(void) >{ > float *a = malloc(sizeof(float) * TESTDIMX * TESTDIMY); > float *b = malloc(sizeof(float) * TESTDIMY * TESTDIMX); > > int *x = malloc(sizeof(int) * NUMVALS); > int *y = malloc(sizeof(int) * NUMVALS); > > float *valsA = malloc(sizeof(float) * NUMVALS); > float *valsB = malloc(sizeof(float) * NUMVALS); > > for (size_t i = 0; i < NUMVALS; ++i) { > x[i] = i % TESTDIMX + 1; > y[i] = i % TESTDIMY + 1; > valsA[i] = ((float)rand()/(float)(RAND_MAX)) * 20; > valsB[i] = ((float)rand()/(float)(RAND_MAX)) * (float)M_PI; > } > > testFunc(a, b, x, y, NUMVALS, valsA, valsB, TESTDIMX); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 20495
: 9469 |
9476