Watch
1
0
Fork
You've already forked NeuroBook
0
forked from rosh/NeuroBook
NeuroBook/Scripts/opencl_test.mq5

79 lines
6.6 KiB
MQL5

2025-05-30 16:12:30 +02:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| OpenCL_Test.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com/en/users/dng |
//+------------------------------------------------------------------+
//| Script for comparing speed of computing the product of a matrix |
//| by vectors using CPU and OpenCL |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link "https://www.mql5.com/en/users/dng"
#property version "1.00"
#property script_show_inputs
//+------------------------------------------------------------------+
//| External parameters |
//+------------------------------------------------------------------+
sinput int Rows = 100000; // Rows in matrix
sinput int Colms = 100; // Columns in matrix
//+------------------------------------------------------------------+
//| Connect libraries |
//+------------------------------------------------------------------+
#include "..\Include\algotrading\mult_vect_ocl.mqh"
//+------------------------------------------------------------------+
//| Script program |
//+------------------------------------------------------------------+
void OnStart()
{
matrix<TYPE> X = matrix<TYPE>::Zeros(Rows, Colms);
vector<TYPE> Y = vector<TYPE>::Zeros(Colms);
vector<TYPE> Z;
for(int i = 0; i < Colms; i++)
{
for(int r = 0; r < Rows; r++)
X[r, i] = MathRand() / (TYPE)32767;
Y[i] = MathRand() / (TYPE)32767;
}
uint start = GetTickCount();
if(!OpenCL_Init(X, Y))
return;
if(!MultOCL(Rows, Colms, Z))
Print("Error OCL function");