![]() ![]() There are proposals and ideas: but these are only proposals. Unfortunately such a "parallel for" does not (yet) exist as a native language element in Free Pascal. Possible candidates for such things are for-loops where it does not matter in which order the individual iterations are done (if they don't depend on each other), in such cases you could transform an ordinary for loop into some kind of parallel for which would put all iterations into a queue and threads from a thread pool would then take them from this queue and execute as many of them in parallel as there are CPU cores until the queue is empty and all threads are idle again. I'm not sure if the calculation of the regression within one bar could easily be split into equal independent portions. Maybe you can find an entirely different algorithm, but I am not enough mathematician to know much about it and cannot suggest one without having to do some extensive searches on the web myself.įor parallel processing you would need threads (as many threads as there are CPU cores and to avoid overhead you should use a tread pool) but you also need to find a way to evenly split the workload into n independent portions in a way that really makes sense. You could try to analyze the generated assembly code of the inner loops and try to find some inefficiencies there (inefficiencies in the way it dereferences the pointers, accesses the memory, unneeded duplicate operations, inefficiencies in the usage of the FPU) and try to rewrite them in hand-written assembly code (there is the asm keyword to insert blocks of assembly code directly in between the Pascal code) but this is really hardcore optimization. You should concentrate on the nested for-loops that are iterated most often and try to find something inside the innermost loops that could be optimized but I don't see anything obvious at first sight, it looks quite efficient. You could try to enable all optimizations but usually the most speed increase can be reached by trying to tweak the code itself. Up = vals+(vals*kstd) //vals is regression's value at last barĭn = vals-(vals*kstd) //vals is the standard deviation value prior to multiplication by kstd (raw std value) UpdateBuffer(history, Bars, degree, period, vals) //populate array "vals" with regression values.īuffer = vals //vals is regression's value at current bar Void updateBuffer(double &history,int bars, int degree, int period, double &vals) ĭouble history // this will later point to the complete chart history Inserted Code #property indicator_chart_window Regression(history, period, degree, bars-1, vals) Procedure updateBuffer(history: PHistory bars: LongInt degree: LongInt period: LongInt vals: PVal) stdcall TBuffer = array of Double įunction regression(history: PHistory period: LongInt degree: LongInt index: LongInt var vals: PVal): Double It returns the current bar's regression, the last bar's regression, and the standard deviation coefficient, by reference to the array "vars." Any tips to speed it up would be greatly appreciated! If anyone is interested, here is the i-Regr port to free pascal that I made. I realize that MT4 won't integrate with a 64bit dll, but can't I make a 32bit dll act as a middle man to pass data between MT4 and the 64bit dll? Then I could possibly squeeze out more processing power.Īlso, how does processor parallelization play in? I know a single instance of MT4 can only use 1 processor core can this limitation be avoided with free pascal? I am quite impressed with the speed increase as it is, but of course I thirst for more! What I am interested in is not necessarily small size, but fast execution speed.Īre there any other compiler settings I should know about to produce a faster-computing. I performed a rudimentary benchmark on the execution speed (during backtest) and found a 64% increase with the Lazarus dll as opposed to iCustom()!!ħbit, I followed the instructions you gave on changing the compiler options to produce a smaller. The syntax was very unfamiliar to me at first but it is so logical and structured that it took no time at all to figure it out. I managed to port the regression indicator. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |