- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I'd like to convert hundreds ofmillions of data points as coordinates on screen, so I'll need to optimize the calculation. The formula is simple, for X coordinate transform:
dPointX = dLeft + (dXValue - xAxisMin) * dXFactor, where dXValue is a series point X value. dLeft, xAxisMin and dXFactor are the same for all items.
By using C#,
int iVectorLen = 500000;
double[] mklVector = new double[iVectorLen];
for(int i=iVectorLen-1;i>=0;--i)
mklVector = xSeriesPoints;
Then, I would like to do
AddToVectorValues(mklVector, iVectorLen, -xAxisMin);
MultiplyVectorValues(mklVector,iVectorLen,dXFactor);
AddToVectorValues(mklVector, iVectorLen, dLeft);
Now, I found dscalfunction, which works for MultiplyVectorValues purposejust fine. But, is there any function toapply the sum operation, for AddToVectorValues purpose? I really couldn't find one, and neither my more MKL-experienced associate.
ByimplementingAddToVectorValues with a for-loop, it will take about ten times more CPU time than a dscal function call.
Any suggestions?
Best regards,
Pasi Tuomainen
I'd like to convert hundreds ofmillions of data points as coordinates on screen, so I'll need to optimize the calculation. The formula is simple, for X coordinate transform:
dPointX = dLeft + (dXValue - xAxisMin) * dXFactor, where dXValue is a series point X value. dLeft, xAxisMin and dXFactor are the same for all items.
By using C#,
int iVectorLen = 500000;
double[] mklVector = new double[iVectorLen];
for(int i=iVectorLen-1;i>=0;--i)
mklVector = xSeriesPoints;
Then, I would like to do
AddToVectorValues(mklVector, iVectorLen, -xAxisMin);
MultiplyVectorValues(mklVector,iVectorLen,dXFactor);
AddToVectorValues(mklVector, iVectorLen, dLeft);
Now, I found dscalfunction, which works for MultiplyVectorValues purposejust fine. But, is there any function toapply the sum operation, for AddToVectorValues purpose? I really couldn't find one, and neither my more MKL-experienced associate.
ByimplementingAddToVectorValues with a for-loop, it will take about ten times more CPU time than a dscal function call.
Any suggestions?
Best regards,
Pasi Tuomainen
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please see at thedaxpy routine. You can try to use them.
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
however, this doesn't seem to give any performance gain. I have to create a separate vector for dLeft values, and initialize it with dLeft valueswith a for loop... Or do you know a MKL routine for initializing a vector with same double-value for each item?
Best regards,
Pasi
however, this doesn't seem to give any performance gain. I have to create a separate vector for dLeft values, and initialize it with dLeft valueswith a for loop... Or do you know a MKL routine for initializing a vector with same double-value for each item?
Best regards,
Pasi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please take a look at the IPP Library function ippiScale.
For something so simple as performing a linear transformation, there is no need to call functions. In fact, the calculation that you described (or, taking for example the generation of a set of temperatures in Kelvin between the freezing and boiling points of water) can be performed in Fortran with the code
An optimizing compiler can perform the core operation inline and with great efficiency. With the -xSSSE3 -O3 options, the Intel Fortran compiler converts the linear transformation into a loop with iVLen/8 repetitions, with each iteration of the loop producing 8 elements of the array.
For something so simple as performing a linear transformation, there is no need to call functions. In fact, the calculation that you described (or, taking for example the generation of a set of temperatures in Kelvin between the freezing and boiling points of water) can be performed in Fortran with the code
[fortran]program scaleI put in the calculation of the mean of dPointX to prevent the optimizer from eliminating the entire calculation.
integer, parameter :: iVLen = 5000000
real, dimension (iVLen) :: dXValue, dPointX
real,volatile :: t0,t1,s
call random_number(dXValue)
call cpu_time(t0)
dPointX = 273.15 + 100.0*dXValue ! linear transformation
call cpu_time(t1)
s=sum(dPointX)/size(dPointX)
write(*,*)t1-t0,s
end program scale
[/fortran]
An optimizing compiler can perform the core operation inline and with great efficiency. With the -xSSSE3 -O3 options, the Intel Fortran compiler converts the linear transformation into a loop with iVLen/8 repetitions, with each iteration of the loop producing 8 elements of the array.
[plain]..B1.7: # Preds ..B1.7 ..B1.6You may attempt to do the equivalent in C++, or you may use the C interoperability features of Fortran 2003.
movaps scale_$DXVALUE.0.1(,%rax,4), %xmm2 #8.1
movaps 16+scale_$DXVALUE.0.1(,%rax,4), %xmm3 #8.1
mulps %xmm1, %xmm2 #8.25
addps %xmm0, %xmm2 #8.1
movaps %xmm2, scale_$DPOINTX.0.1(,%rax,4) #8.1
mulps %xmm1, %xmm3 #8.25
addps %xmm0, %xmm3 #8.1
movaps %xmm3, 16+scale_$DPOINTX.0.1(,%rax,4) #8.1
addq $8, %rax #8.1
cmpq $500000, %rax #8.1
jb ..B1.7 # Prob 99% #8.1
[/plain]
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page