OpenCL: pruebas de implementación interna en MQL5 - página 18

 
MetaDriver:
Yo también lo instalé en mi dispositivo. Se actualizó el controlador (la instalación fue bien) pero ahora ControlCenter ha desaparecido por completo de la bandeja del sistema y ni siquiera se puede iniciar manualmente. ¿Está todo bien?

tuve el mismo problema cuando descargué el software del controlador de Vista desde Win7 y ControlCenter comenzó a aparecer en la bandeja

Me pueden decir si hay emulador OpenCL http://developer.amd.com/zones/opensource/pages/ocl-emu.aspx , es conveniente cambiar el código en el portátil durante un día y luego utilizarlo en el PC para la optimización. Supongo que MT5 no funcionará con el emulador OpenCL ?

Home - AMD
  • developer.amd.com
If you want faster apps, you’ll want to use heterogeneous computing technologies. We’re here to make that happen, with plenty of tools and resources. And if you’re thinking about architecture, HSA is going to rock your world—learn more.
 

IgorM:

¿que MT5 no funcionará con el emulador OpenCL?


Renat:
Mientras que el terminal utiliza rígidamente OpenCL sólo en la GPU, en la próxima compilación añadiremos el uso automático de la CPU si no hay GPU.
 
IgorM:

tuve el mismo problema cuando descargué el software del controlador de Vista desde Win7 y ControlCenter comenzó a aparecer en la bandeja

Me puedes decir, hay un emulador OpenCL http://developer.amd.com/zones/opensource/pages/ocl-emu.aspx, es conveniente cambiar el código en el portátil durante el día, y luego utilizarlo en el PC para la optimización, supongo que MT5 no funcionará con el emulador OpenCL ?

1. Creo que tengo la versión correcta. Lo he sacado de aquí: http: //developer.amd.com/Downloads/AMD-APP-SDK-v2.6-Windows-64.exe

2. Por supuesto, MT5 no funcionará con el emulador. Pero se puede utilizar para la depuración y los programas listos (depurados) se pueden insertar en el código mql5.

Yo también he descargado el emulador. Todavía no he podido usarlo.

 
MetaDriver:

1. Parece ser la versión correcta. Lo he sacado de aquí: http: //developer.amd.com/Downloads/AMD-APP-SDK-v2.6-Windows-64.exe

Empiezo a buscar los drivers de ATI desde aquí: http://www.amd.com/ru/Pages/AMDHomePage.aspx
Глобальный поставщик инновационных графических карт, процессоров и решений для мультимедиа | AMD
  • www.amd.com
Advanced Micro Devices (NYSE: AMD) — это инновационная технологическая компания, ориентированная на сотрудничество с заказчиками и партнерами с целью разработки вычислительных и графических решений нового поколения для офиса, дома и игр.
 
MetaDriver:

Hubo un fallo, estoy de acuerdo. Pero desapareció después de un reinicio... Ahora que tengo el icono, lo uso siempre para comprobar la temperatura y la velocidad del refrigerador, así que no puedo ir a ningún sitio sin él.

Estoy de acuerdo con IgorM en que siempre descargo los drivers de http://sites.amd.com/us/game/downloads/Pages/radeon_win7-64.aspx ( enlace a la página de HD 6xxx WIN7 x64).

Y el propio centro Catalyst para la misma versión: http://www2.ati.com/drivers/12-1_vista_win7_64_dd_ccc.exe

 
WChas:

1. Hubo un fallo, estoy de acuerdo. Pero desapareció después de un reinicio... Ahora que tengo el icono, lo uso siempre para comprobar la temperatura y la velocidad del refrigerador, así que no puedo ir a ningún sitio sin él.

2. Estoy de acuerdo con IgorM, siempre descargo los controladores de http://sites.amd.com/us/game/downloads/Pages/radeon_win7-64.aspx ( enlace a la página para HD 6xxx WIN7 x64).

3. y el propio centro Catalyst para la misma versión: http://www2.ati.com/drivers/12-1_vista_win7_64_dd_ccc.exe

1. No tengo nada. Reiniciar no ayuda.

Parece que le falta algo de dll para que sea feliz, te preguntaré si puedo averiguarlo. :) // si yandex no puede ayudar.

// Sobre las neveras, las estoy vigilando bien. AI Suite II está vivo y funcionando, sólo el Centro de Control de Catalist está muerto.

2. También estoy buscando todo allí. Todo funciona, y Catalist también funcionaba, hasta que pasé la nueva versión.

3. Tengo el mismo archivo. 151765KB en mi disco, si lo necesitas. :)

Gracias por las respuestas.

 

¡Renat! ¿Qué pasa con el multithreading? Ejecuté varios scripts de prueba en diferentes gráficos y empezaron a mezclar sus lecturas, robándose búferes unos a otros todo el tiempo. Problemas, sin embargo.

// He limpiado el monitor, he pateado la unidad del sistema - nada ayuda.

 
MetaDriver:

Renat, ¿qué pasa con el multithreading? Ejecuté varios scripts de prueba en diferentes gráficos y empezaron a mezclar sus lecturas, robándose búferes unos a otros todo el tiempo. Problemas, sin embargo.

// He limpiado el monitor, he pateado la unidad del sistema - nada funciona.

Si nos referimos al ejemplo del test de Mandelbrot, tenga en cuenta que la imagen se escribe en el mismo archivo. Por eso parece que diferentes hilos estropean el archivo BMP de cada uno.

Pruebe este script - funciona (rand) con todos los hilos y no tiene más conflictos:

//+------------------------------------------------------------------+
//|                                                   OpenCLTest.mq5 |
//|                        Copyright 2011, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Код функции OpenCL                                               |
//+------------------------------------------------------------------+
const string cl_src=
                    "__kernel void MFractal(                                    \r\n"
                    "                       float x0,                           \r\n"
                    "                       float y0,                           \r\n"
                    "                       float x1,                           \r\n"
                    "                       float y1,                           \r\n"
                    "                       uint  max,                          \r\n"
                    "              __global uint *out)                          \r\n"
                    "  {                                                        \r\n"
                    "   size_t  w = get_global_size(0);                         \r\n"
                    "   size_t  h = get_global_size(1);                         \r\n"
                    "   size_t gx = get_global_id(0);                           \r\n"
                    "   size_t gy = get_global_id(1);                           \r\n"
                    "   float dx = x0 + gx * (x1-x0) / (float) w;               \r\n"
                    "   float dy = y0 + gy * (y1-y0) / (float)h;                \r\n"
                    "   float x  = 0;                                           \r\n"
                    "   float y  = 0;                                           \r\n"
                    "   float xx = 0;                                           \r\n"
                    "   float yy = 0;                                           \r\n"
                    "   float xy = 0;                                           \r\n"
                    "   uint i = 0;                                             \r\n"
                    "   while ((xx+yy)<4 && i<max)                              \r\n"
                    "     {                                                     \r\n"
                    "      xx = x*x;                                            \r\n"
                    "      yy = y*y;                                            \r\n"
                    "      xy = x*y;                                            \r\n"
                    "      y = xy+xy+dy;                                        \r\n"
                    "      x = xx-yy+dx;                                        \r\n"
                    "      i++;                                                 \r\n"
                    "     }                                                     \r\n"
                    "   if(i==max)                                              \r\n"
                    "      out[w*gy+gx] = 0;                                    \r\n"
                    "   else                                                    \r\n"
                    "      out[w*gy+gx] = (uint)((float)0xFFFFFF/(float)max)*i; \r\n"
                    "  }                                                        \r\n";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
#define SIZE_X 512
#define SIZE_Y 512
//+------------------------------------------------------------------+
//| Заголовок BMP файла                                              |
//+------------------------------------------------------------------+
struct BitmapHeader
  {
   ushort            type;
   uint              size;
   uint              reserv;
   uint              offbits;
   uint              imgSSize;
   uint              imgWidth;
   uint              imgHeight;
   ushort            imgPlanes;
   ushort            imgBitCount;
   uint              imgCompression;
   uint              imgSizeImage;
   uint              imgXPelsPerMeter;
   uint              imgYPelsPerMeter;
   uint              imgClrUsed;
   uint              imgClrImportant;
  };
//+------------------------------------------------------------------+
//| Запись битмапа в файл                                            |
//+------------------------------------------------------------------+
bool SaveBitmapToFile(const string filename,uint &bitmap[],const BitmapHeader &info)
  {
//--- откроем файл
   int file=FileOpen(filename,FILE_WRITE|FILE_BIN);
   if(file==INVALID_HANDLE)
     {
      Print(__FUNCTION__," error opening '",filename,"'");
      return(false);
     }
//--- запишем заголовок и само тело
   if(FileWriteStruct(file,info)==sizeof(info))
     {
      if(FileWriteArray(file,bitmap)==ArraySize(bitmap))
        {
         FileClose(file);
         return(true);
        }
     }
//--- неудачно получилось, удалим файл от греха подальше
   FileClose(file);
   FileDelete(filename);
   Print(__FUNCTION__," error writting '",filename,"'");
//--- вернем ошибку
   return(false);
  }
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   int cl_ctx;
   int cl_prg;
   int cl_krn;
   int cl_mem;
   int fileidx=MathRand()&255;
//--- инициализируем OpenCL объекты
   if((cl_ctx=CLContextCreate())==0)
     {
      Print("OpenCL not found");
      return;
     }
   if((cl_prg=CLProgramCreate(cl_ctx,cl_src))==0)
     {
      CLContextFree(cl_ctx);
      Print("OpenCL program create failed");
      return;
     }
   if((cl_krn=CLKernelCreate(cl_prg,"MFractal"))==0)
     {
      CLProgramFree(cl_prg);
      CLContextFree(cl_ctx);
      Print("OpenCL kernel create failed");
      return;
     }
   if((cl_mem=CLBufferCreate(cl_ctx,SIZE_X*SIZE_Y*sizeof(float),CL_MEM_READ_WRITE))==0)
     {
      CLKernelFree(cl_krn);
      CLProgramFree(cl_prg);
      CLContextFree(cl_ctx);
      Print("OpenCL buffer create failed");
      return;
     }
//--- подготовимся к выполнению
   float x0       =-2;
   float y0       =-0.5;
   float x1       =-1;
   float y1       = 0.5;
   uint  max      = 20000;
   uint  offset[2]={0,0};
   uint  work  [2]={SIZE_X,SIZE_Y};
//--- выставляем неизменяемые параметры функции OpenCL
   CLSetKernelArg(cl_krn,4,max);
   CLSetKernelArgMem(cl_krn,5,cl_mem);
//--- подготовим буфер для вывода пикселей
   uint buf[];
   ArrayResize(buf,SIZE_X*SIZE_Y);
//--- подготовим заголовок
   BitmapHeader info;
   ZeroMemory(info);
   info.type          =0x4d42;
   info.size          =sizeof(info)+SIZE_X*SIZE_Y*4;
   info.offbits       =sizeof(info);
   info.imgSSize      =40;
   info.imgWidth      =SIZE_X;
   info.imgHeight     =SIZE_Y;
   info.imgPlanes     =1;
   info.imgBitCount   =32;
   info.imgCompression=0;                // BI_RGB
   info.imgSizeImage  =SIZE_X*SIZE_Y*4;
//--- создаём объект для вывода графики
   ObjectCreate(0,"x",OBJ_BITMAP_LABEL,0,0,0);
   ObjectSetInteger(0,"x",OBJPROP_XDISTANCE,4);
   ObjectSetInteger(0,"x",OBJPROP_YDISTANCE,26);
//--- рендерим пока не остоновят снаружи
   while(!IsStopped())
     {
      uint x=GetTickCount();
      //--- выставляем плавающие параметры
      CLSetKernelArg(cl_krn,0,x0);
      CLSetKernelArg(cl_krn,1,y0);
      CLSetKernelArg(cl_krn,2,x1);
      CLSetKernelArg(cl_krn,3,y1);
      //--- рендерим кадр
      CLExecute(cl_krn,2,offset,work);
      //--- забираем данные кадра
      CLBufferRead(cl_mem,buf);
      //--- выведем время рендера
      Comment(IntegerToString(GetTickCount()-x)+" msec per frame");
      //--- сохраняем кадр в памяти и рисуем его
      SaveBitmapToFile("Mandelbrot"+IntegerToString(fileidx)+".bmp",buf,info);
      ObjectSetString(0,"x",OBJPROP_BMPFILE,NULL);
      ObjectSetString(0,"x",OBJPROP_BMPFILE,"\\Files\\Mandelbrot"+IntegerToString(fileidx)+".bmp");
      ChartRedraw();
      //--- небольшая задержка и обновление параметров для следующего кадра
      Sleep(10);
      x0+=0.001 f;
      x1-=0.001 f;
      y0+=0.001 f;
      y1-=0.001 f;
     }
//--- удаляем объекты OpenCL
   CLBufferFree(cl_mem);
   CLKernelFree(cl_krn);
   CLProgramFree(cl_prg);
   CLContextFree(cl_ctx);
  }
//+------------------------------------------------------------------+

Ten en cuenta que varios scripts que utilicen OpenCL al mismo tiempo pueden provocar una pérdida no lineal del rendimiento de la GPU.

 
Renat:

1. Si nos referimos al ejemplo de la prueba de Mandelbrot, observe que la imagen se escribe en el mismo archivo. Por eso los diferentes hilos estropean el archivo BMP de cada uno.

Prueba este script - funciona con cada hilo (rand) con su propia imagen y ya no hay conflictos:

2. pero ten en cuenta que varios scripts que utilicen OpenCL al mismo tiempo provocarán una pérdida no lineal del rendimiento de la GPU.

1. ¡Mierda! Podría haberlo adivinado yo mismo. Perdón por el exceso de ruido.

Miró al escéptico. Así es, sí. Sólo que mejor.

int fileidx=ChartID();

Por si sirve de algo...

2. Eso es lo que quería ver. Sólo para considerar... :)

 

MetaDriver:

...

3. Bueno, es el mismo archivo que tengo. 151765KB en el disco, en todo caso. :)

...

El archivo de arriba es una descarga del mío, el de abajo de tu enlace. Tamaño completamente diferente.... )

Razón de la queja: