FLOP measurement - intel

I'm trying to estimate FLOPS for my application using intel vtune Amplifier and I'm using this post here as a guideline : https://software.intel.com/en-us/articles/estimating-flops-using-event-based-sampling-ebs/
The problem is that I can't find the FP_COMP_OPS_EXE event in vtune gui. When I run amplxe-cl with this event config, I get the following error:
amplxe: Error: Invalid Event FP_COMP_OPS_EXE.X87 discarded.
I'm working on CentOS and my processor is intel Xeon
Any help would be appreciated

The available events set can change between processors generations. It is important to know exactly your processor name.
The event you mentioned exist for Intel Xeon v2 (Ivybridge based) and you can use following formula to measure the number of floating points operations:
FP_COMP_OPS_EXE.SSE_SCALAR_SINGLE + 4 * FP_COMP_OPS_EXE.SSE_PACKED_SINGLE + 8 * SIMD_FP_256.PACKED_SINGLE + FP_COMP_OPS_EXE.SSE_SCALAR_DOUBLE + 2 * FP_COMP_OPS_EXE.SSE_PACKED_DOUBLE + 4 * SIMD_FP_256.PACKED_DOUBLE + FP_COMP_OPS_EXE.X87
For Haswell based processors (Xeon v3) there are no such events and FLOPs calculation is not possible there.
For Broadwell based the formula will be following:
FP_ARITH_INST_RETIRED.SCALAR_SINGLE + 4 * FP_ARITH_INST_RETIRED.128B_PACKED_SINGLE + 8 * FP_ARITH_INST_RETIRED.256B_PACKED_SINGLE + FP_ARITH_INST_RETIRED.SCALAR_DOUBLE + 2 * FP_ARITH_INST_RETIRED.128B_PACKED_DOUBLE + 4 * FP_ARITH_INST_RETIRED.256B_PACKED_DOUBLE + INST_RETIRED.X87

Related

Should I shrink multiple factor variables into one?

* NEW CAR: Purpose for this credit/application? (Binary)
+ 0: No
+ 1: Yes
* USED CAR: Purpose for this credit/application? (Binary)
+ 0: No
+ 1: Yes
* FURNITURE: Purpose for this credit/application? (Binary)
+ 0: No
+ 1: Yes
* RADIO/TV: Purpose for this credit/application? (Binary)
+ 0: No
+ 1: Yes
* EDUCATION: Purpose for this credit/application? (Binary)
+ 0: No
+ 1: Yes
* RETRAINING: Purpose for this credit/application? (Binary)
+ 0: No
+ 1: Yes
So these are some of the variables I have for a new dataset. Since they are related to the purpose behind loan applications, would it be wise to group them under one variable that I could call "Purpose"?
I plan on running a Random Forest Model. I want to try out both ways and I probably will as soon as I conduct an analysis as it is.
To be clear, I've already checked that two variables don't hold a "Yes" in the same row number.
Is there any downside to creating ONE vector/variable that looks like when creating decision trees?:
c("NEW_CAR", "RADIO/TV", "RETRAINING", "FURNITURE", "USED_CAR", "USED_CAR", "NEW_CAR")
I'm worried that there is a major downside as each current variable is binary and a tree can only split into two nodes. Perhaps it doesn't make a difference considering that there could be multiple nodes with a choice between the current variables.
I'm new. Thank you.
Thank You.

How to calculate Received Signal Strength (RSS) and path loss Error in dB?

supposed that the measurement RSS is "-70dBm" and the predicted RSS is "-68dBm, the transmission power of antenna is "-12dBm",
then if the following equation is right? if not, how to calculate it?
Error = |10 * log10 (70/12) - 10 * log10 (68/12)| = 10 * log10 (70/68)
now my measurement is the RSS in dBm, how to convert it into dB?
This often confuses folks in my experience, and as such warrants a thorough explanation.
The "m" in "dBm" means relative to 1 milliwatt. It is typically used for absolute measurements, whereas "regular" dBs are typically used for power gains/losses/diffs.
Example:
in/tx out/rx
1w .5w
(1 milliwatt = 0.001)
10log(1/0.001) = 30dBm
10log(0.5/0.0001) = 27dBm
loss = 3dB
10log(1) = 0dB
10log(0.5) = 3dB
loss still is 3dB
(note there is an implied /1w here since the argument to log must be unit-less, e.g. 0.5w/1w = 0.5 "flat" (aka no units))
So in the context of power differences, the m does not matter.
Things to note:
1/2 of power lost == -3dB gain (or +3dB loss)
power gains/losses in series are added/subtracted when in dBs -vs- multipled/divided when in watts
0 watts == -infinity dB
0 dBm == 1 milliwatt
log here is base 10 (not 2 nor e)
reletiveGainOrLoss = 10^(valueOfGainOrLossInDb/10)
valueOfPowerInMilliwatts = 10^(valueOfPowerInDbm/10)
In your example, I'll presume by error you mean the error of the predicted loss relative measured loss:
predicted loss =
known transmission power - predicted RSS =
-12dBm - -68dBm =
56dB
measured loss =
known transmission power - measured RSS =
-12dBm - -70dBm =
58dB
error of predicted loss relative to measured loss =
|predicted loss - measured loss| =
|56dB - 58dB| =
2dB (==2dBms, but for diffs we should drop the m) =
Or more directly: 70 - 68 (so easy with dBs!)
This equates to a 63% error (or 58, depending on how it is done):
10^(-2dB/10) =
0.63
(10^(2dB/10) =
1.584893192461113
In millwatts:
10^(valueInDbm/10) =
10^(-70/10) = 0.0000001 milliwatts
10^(-68/10) = 0.000000158489319 milliwatts
10^(-12/10) = 0.063095734448019 milliwatts
As a sanity check:
(0.0000001/0.063095734448019 - 0.000000158489319/0.063095734448019) / (0.0000001/0.063095734448019) =
(0.000001584893192 - 0.000002511886428) / 0.000001584893192 =
-0.000000926993236 / 0.000001584893192 =
-0.584893190707832
(note that doing it in watts is much more laborious! (not to even mention float errors))
To answer your other question regarding:
Error = |10 * log10 (70/12) - 10 * log10 (68/12)| = 10 * log10 (70/68)
The first equation is nonsensical; as discussed above: for dBs we add/subtract -vs- multiply/divide. The second equation is however true, based on one of the rules of logs:
log a + log b = log ab
When the RSS in dBm, the path loss is equal to the difference between the transmission RSS and received RSS, the unit of path loss in this case is dB.

Is there symbolic ODE solver in R ? (ODE = ordinary differential equation)

Question: Is there symbolic ODE solver in R ? (ODE = ordinary differential equation)
I am afraid there is NO... but let me confirm from experts ...
For example, solve:
> (5x-6)^2 y' = 5(5x-6) y - 2
Here: y - unknown function, y' - its derivative
(It is easy to solve by hands: y = 1/(5(5x-6)) + C* (5x-6) , but I want to get that answer from R).
What I know:
1) There are NUMERICAL (not symbolic) solvers:
I know there are numerical ODE solvers like library(deSolve),
see answer here:
Can R language find a generic solution of the first order differential equation?
2) There are symbolic packages : (but they do not seem to contain ODE solvers)
There are symbolic packages in R like
see Ryacas and rSymPy and also some basic symbolic calculation in base R, see:
https://stats.stackexchange.com/questions/4775/symbolic-computation-in-r/4778
3) Brief overview of various differential equations solvers for R:
https://cran.r-project.org/web/views/DifferentialEquations.html
However I was unable to find sumbolic ODE solvers (((
I've had a play around with Ryacas, and you can in fact get symbolic solutions to some simple ODEs without too much work. Unfortunately, YACAS fails to find a solution for your example ODE. However, depending on the ODEs you are exploring, this might still be of use. If not, I'm happy to remove this post.
As an initial simple example, let's consider the following ODE: y'' + y = 0:
Load the library
library(Ryacas);
Since Ryacas is just an interface to YACAS, we can use YACAS' OdeSolve to solve the ODE
yacas("OdeSolve( y\'\' + y == 0 )")
#expression(C70 * exp(x * complex_cartesian(0, -1)) + C74 * exp(x *
# complex_cartesian(0, 1)))
This gives the correct solution const * exp(- ix) + const * exp(+ ix).
Unfortunately when using your particular example, OdeSolve fails to find a solution:
yacas("OdeSolve( y\'\' == (5 * (5 * x - 6) * y - 2) / (5 * x - 6)^2 )")
#expression(y(2) - (5 * ((5 * x - 6) * y(0)) - 2)/(5 * x - 6)^2)
The same happens when we use the YACAS online demo.

How to calculate log(sum of terms) from its component log-terms

(1) The simple version of the problem:
How to calculate log(P1+P2+...+Pn), given log(P1), log(P2), ..., log(Pn), without taking the exp of any terms to get the original Pi. I don't want to get the original Pi because they are super small and may cause numeric computer underflow.
(2) The long version of the problem:
I am using Bayes' Theorem to calculate a conditional probability P(Y|E).
P(Y|E) = P(E|Y)*P(Y) / P(E)
I have a thousand probabilities multiplying together.
P(E|Y) = P(E1|Y) * P(E2|Y) * ... * P(E1000|Y)
To avoid computer numeric underflow, I used log(p) and calculate the summation of 1000 log(p) instead of calculating the product of 1000 p.
log(P(E|Y)) = log(P(E1|Y)) + log(P(E2|Y)) + ... + log(P(E1000|Y))
However, I also need to calculate P(E), which is
P(E) = sum of P(E|Y)*P(Y)
log(P(E)) does not equal to the sum of log(P(E|Y)*P(Y)). How should I get log(P(E)) without solving for P(E|Y)*P(Y) (they are extremely small numbers) and adding them.
You can use
log(P1+P2+...+Pn) = log(P1[1 + P2/P1 + ... + Pn/P1])
= log(P1) + log(1 + P2/P1 + ... + Pn/P1])
which works for any Pi. So factoring out maxP = max_i Pi results in
log(P1+P2+...+Pn) = log(maxP) + log(1+P2/maxP + ... + Pn/maxP)
where all the ratios are less than 1.

derivative of a function

I am using D to get derivatives of a function. However, R does not simplify the expression when returning the derivative. I need to figure out if a function has a derivative that can be expressed generically. Is there some way in R to simplify the expression?
> D(expression(sqrt(1 - x^2)), 'x')
-(0.5 * (2 * x * (1 - x^2)^-0.5))
> D(D(expression(sqrt(1 - x^2)), 'x'), 'x')
-(0.5 * (2 * (1 - x^2)^-0.5 - 2 * x * (-0.5 * (2 * x * (1 - x^2)^-1.5))))
Secondly, is there a way in R to do numerical integration?
library(Ryacas)
x <- Sym("x")
Simplify(deriv(sqrt(1 - x^2),x,2)) # return the result simplified
gives
expression((x^2 - 1 - x^2)/root(1 - x^2, 2)^3)
You can also try
PrettyForm(Simplify(deriv(sqrt(1 - x^2),x,2)))
which gives
2 2
x - 1 - x
---------------
3
/ 2 \
Sqrt\ 1 - x /
As for numerical integration try giving this to see what is available
library(sos)
findFn('{numerical+integration}')
As far as I know, R will not simplify the result of D(). It sounds as though you want a proper computer algebra system, and R is definitely not a full CAS. Mathematica and Maple are the most well-known, but there are also a number of open-source alternatives (as discussed on this SO post).
R can do numerical integration - for this kind of question it is worth searching in the R help pages first (i.e. help.search('integrate')). You can use integrate() in the stats package. There is also area() in the MASS package, but that is much simpler (i.e. for demonstration purposes).

Resources