Here's what you can do with OpenCL directly in MetaTrader 5 without any DLLs - page 5

 
Renat Fatkhullin:

Against this background AMD looks advantageous not only due to obviously faster math calculations (mining farms are usually built on AMD), but also for its strategy of open standards (they have opened up and are promoting a lot to the public). The introduction of OpenCL 2.0 in AMD cards has brought this spec very close to CUDA capabilities and now there is no point in laying the groundwork for CUDA at all.

That is useful information, while about 7 years ago I was playing around with CUDA and thought it still rules the game.

My question is: what about OpenCL debuggers nowadays? I am not referring to MT5 terminal but to the MT5 terminal in general. So far, I have only seen a debugger from Intel as a plugin of Visual Studio and a stand-alone debugger (depricated) from the same company. But it seems that it is Intel's processors and embedded graphics that are intended for this purpose. I do not understand well how to debug parallel code at all - for me it is only a black box yet.

 

You can only work with CUDA for yourself or for specific areas where you can require Nvidia cards explicitly.

Yes, CUDA used to have more features. However, with AMD hardware coming out with OpenCL 2.0 and the new version of OpenCL 2.1 there is no point in sitting under vendor lock-in. Especially when that vendor also undercuts the functionality.

In terms of maximum coverage, there is only one choice - OpenCL, which also works fine on normal processors. That is, you don't have to demand the unconditional presence of the GPU or write two versions of code for the GPU and the CPU. Once written, the OpenCL code will work on different configurations.

CUDA/OpenCL can only be debugged with specialized debuggers. There can be no miracle here.

 
Renat Fatkhullin:

in the example

if((cl_ctx=CLContextCreate())==INVALID_HANDLE)

On configurations with a CPU-available device, "OpenCL not found" is displayed

Otherwise.

if((cl_ctx=CLContextCreate(CL_USE_ANY))==INVALID_HANDLE)

works

*The issue is the default device selection

 

Can we have all this in a nice form, without all the quotes? It's too inconvenient for perception and creation.

And for neural networks we should have standard classes, and it's possible to use opcl instantly) like wellslab

"#define HL1Count "             + (string)hl1NeuronCount + "                     \r\n"
          "#define HL2Count "             + (string)hl2NeuronCount + "                     \r\n"
          //------------------------------------------------------------------------------------
          "#define NeuronSensitivity  "   + (string)NeuronSensitivity_P + "                \r\n"
          //------------------------------------------------------------------------------------
          "#define sampleCount "          + (string)sampleCount + "                        \r\n"
          //------------------------------------------------------------------------------------
          "#define signalCount "          + (string)signalCount + "                        \r\n"
          //------------------------------------------------------------------------------------
          "#define StrArrSaSize "         + (string)(sizeof(ArrSample) / sizeof(float)) + "\r\n"
          "typedef struct{float C[StrArrSaSize];} ArrSa;                                   \r\n"
          //------------------------------------------------------------------------------------
          "#define StrArrWeSize "         + (string)(sizeof(ArrWe) / sizeof(float)) + "    \r\n"
          "typedef struct{float C[StrArrWeSize];} ArrWe;                                   \r\n"
          //------------------------------------------------------------------------------------
          "#define StrArrCrSize "         + (string)(sizeof(ArrCr) / sizeof(float)) + "    \r\n"
          "typedef struct{float C[StrArrCrSize];}ArrCr;                                    \r\n"
          //------------------------------------------------------------------------------------
          "#define Spread "               + (string)(Spread_P * Point()) + "               \r\n"
          //------------------------------------------------------------------------------------
          "#define Point "                + (string)Point() + "                            \r\n"
          "#define SL "                   + (string)(StopLoss_P * Point()) + "             \r\n"
          "#define TP "                   + (string)(TakeProfit_P * Point()) + "           \r\n"
          //------------------------------------------------------------------------------------
          "                                                                                \r\n"
          "__kernel void Work(__global ArrSa *Sample,                                      \r\n"
          "                   __global ArrWe *Weights,                                     \r\n"
          "                   __global ArrCr *Result)                                      \r\n"
          "{                                                                               \r\n"
          "  int thread       = get_global_id(0);                                          \r\n"
          "                                                                                \r\n"
          "  //------------------Переменные нейронной сети---------------------------------\r\n"
 
Maxim Dmitrievsky:

Can we have all this in a nice form, without all the quotes? It's awkward for perception and creation.

And for neural networks we should have standard classes, and it's possible to use opcl instantly) like wellslab

Well, why not? Look, there isn't a single specific function that MQL doesn't know. I used MQL to write and debug this function for OCL and then I just hardened it all. You may even make a code converter in OCL, but I don't see any particular point in doing it for myself. Maybe MQ will do it, but I doubt it.
 
Renat Fatkhullin:

This is a demonstration not only of GPU calculations in the MQL5 code, but also of the graphical capabilities of the terminal:

The full source code as a script is attached. The bug on OpenCL 1.2 has been fixed.

I also know how to embroider. And on a typewriter... (c) What's all this trading terminal for?
 
Will it go to the cloud for agents ?
 
GKS:
Will it go to the cloud for agents ?
No
 

All great, but! There is a big problem with OCL and in general with all means of parallelization - very few algorithms can be effectively parallelized. Why in the examples of parallel computing so popular are simulation of waves, ball falling on a pyramid with their destruction, i.e. everything that can be broken into small pieces and computed on your own processor.

For fora/bear, of course, these are neural networks, various Fourier transforms, wavelets, filters, etc., all of which are perfectly parallel. But there are linear algorithms that cannot be paralleled at all. As a rule, it is when the result of the next algorithm's step is based on the result of the previous step.

I wrote this for those who are thinking that I'll buy two cool video cards and everything will work fine in my tester.