Threads on same core accessing same cache line

I am working in a bare-metal environment and thus evaluating performance at a low-level. How should I expect two threads on the same core to perform when writing to different sections of the same cache line? I am somewhat new to multicore/multithrea...
more »

2017-04-19 18:04 (1) Answers

Multithreading - Raytracer

I've finished my raytracer now but im trying to learn threads to optimize the render time. To represent each pixels of my window im using a int8_t * (4 int8_t / pixel for R/G/B/A). Here is a sample of what im trying to do : Number of threads set : 4...
more »

2017-04-18 23:04 (1) Answers

React Dont Rerender Existing DOM Children

How can I render a react element without rerendering existing child content? I am not looking to avoid rerendering an existing react child, as in my case there are no existing react children, because the html came directly from the server. For exam...
more »

2017-04-16 01:04 (0) Answers

Optimize summation code

Its from an interview: int fn(int a, int b) { int sum = 0; for (int i = a * 4; i>0; i--) { sum += b*i*i; } return sum; } How can this code be further optimized? I know there is a summation formula, but I dont think...
more »

2017-04-14 05:04 (4) Answers

scipy.optimize with non linear constraints

I have non-linear function with non-linear constraints and I'd like to optimize it. I don't know how to define non-linear constraints using scipy.optimize. My code so far looks like: from math import cos, atan import numpy as np from scipy.optimize ...
more »

2017-04-09 19:04 (1) Answers

Rewrite rules with newtype

Rewrite rules can help with your program optimization. And I wonder if they would work if I wrap my objects in newtype. As it known, newtype doesn't bring performance penalties, it's a compile-time wrapper which is gone at runtime. So I wonder if rew...
more »

2017-04-09 11:04 (1) Answers

Code optimization python

I wrote the below function to estimate the orientation from a 3 axes accelerometer signal (X,Y,Z) X.shape Out[4]: (180000L,) Y.shape Out[4]: (180000L,) Z.shape Out[4]: (180000L,) def estimate_orientation(self,X,Y,Z): sigIn=np.array([X,Y,Z]).T ...
more »

2017-04-08 15:04 (1) Answers

VBA - optimize runtime for hiding columns

I have a worksheet with a table of 50 years, starting from 2017 to 2066. This macro is making a print area for the first 10 years, with the tenth year being a user input and hiding any other columns. We would remove the 10th consecutive year (2026) a...
more »

2017-03-24 23:03 (1) Answers

Fastest way to search in sorted static array

I am looking for the fastest way to search in a sorted, fixed array of 32 bit keys. The array size and data is static and will never change. The size of this array is ~1000-10000 unique elements. The search range is significantly broader (~100000) so...
more »

2017-03-24 01:03 (1) Answers

Scipy NNLS using mask

I am performing non-negative least squares using scipy. A trivial example would be as follows: import numpy as np from scipy.optimize import nnls A = np.array([[60, 70, 120, 60],[60, 90, 120, 70]], dtype='float32') b = np.array([6, 5]) x, res = nnl...
more »

2017-03-21 11:03 (1) Answers

ES6 Tail Recursion Optimisation Stack Overflow

Having read Dr Rauschmayer's description of recursive tail call optimisation in es6, I've since been trying to recreate the 'zero-stack' execution of the recursive factorial function he details. Using the Chrome debugger to step between stack frames,...
more »

2017-03-14 15:03 (1) Answers

Optimize Case Statement

We have a method for writing command data to a device. The method first converts the data to the form accepted by the device and then writes the data to the serial port. The data conversion is done with a case statement as given below. For 10 command...
more »

2017-03-08 15:03 (5) Answers

Python scipy optimization does not find minimum

Trying to use scipy.optimize.minimize, it seems like the optimization fails. I did the following: 1. The objective function is: f(x)= x[0]+x[1]+x[2]+x[3]+10 2. The constraint is: x_i >= 0 3. The initial guess is: x0 = [1,1,1,1] Very trivial proble...
more »

2017-03-03 20:03 (1) Answers

Speed up the lookup procedure

I have two tables: coc_data and DT. coc_data table contains co-occurrence frequency between pair of words. Its structure is similar to: word1 word2 freq 1 A B 1 2 A C 2 3 A D 3 4 A E 2 Second tabl...
more »

2017-02-27 11:02 (1) Answers