Forum: PC-Programmierung OpenCL mit Code::Blocks einrichten.Probleme


von Roland (Gast)


Lesenswert?

Hallo...,
habe versucht Code:Blocks zu konfigurieren, dass ich Open CL verwenden 
kann, aber irgendie funktioniert das nicht so ganz bei mir.

Ich verwende:
Win7 64x
Code::Blocks 13.12
AMD APP SDK 3.0.130.135
OpenCL™ Version 21.19.407.0

hier die Anleitung die ich verwendete ... aber aus welchem Grund auch 
immer bei mir nicht funktioniert ..... >:(

httb://www.obellianne.fr/alexandre/tutorials/OpenCL/tuto_opencl_codebloc 
ks.php

(!!!dass der link funktioniert das httb in http umwandeln!!!)

Ich bekomme immer dieser Meldung wenn ich builden will:

-------------- Build: Debug in test_1 (compiler: OpenCL™)---------------

mingw32-g++.exe -Wall -g -I"C:\Program Files (x86)\AMD APP 
SDK\3.0\include\CL" -c C:\Work\Test\test_1.cl -o obj\Debug\test_1.o
mingw32-g++.exe: warning: C:\Work\Test\test_1.cl: linker input file 
unused because linking not done
Linking stage skipped (build target has no object files to link)
Nothing to be done (all items are up-to-date).

Kann mir jemand bitte helfen.

von WaMin (Gast)


Lesenswert?

Roland schrieb:

> build target has no object files to link

Fehlermeldung steht doch da.

von Roland (Gast)


Lesenswert?

Danke WaMin für ihren Hinweis, aber soweit bin ich schon :)
Wie behebe ich nun das Problem?

von Roland (Gast)


Lesenswert?

#push
Kann mir echt keiner helfen?
Was fehlt euch dass Ihr mir eventuell schneller helfen könnt?
mfg.

von Dr. Sommer (Gast)


Lesenswert?

Verrate erstmal warum deine Datei die Endung .cl hat, das verwirrt den 
GCC.

von Roland (Gast)


Lesenswert?

nochmal zum mitlesen bevor ich den PC aus dem Fenster werfe:
Ich möchte openCL in Code::Blocks einrichten so dass es funktioniert 
nicht mehr nicht weniger. Die Anleitung in meinem alten Link hatte bei 
mir nicht funktioniert und ich kann das Projekt nicht builden. Hat nun 
jemand eine Funktionierende Anleitung?

@Dr.Sommer ich habe alles schon probiert .cpp .cl .c völlig egal es 
funktioniert einfach nicht.

Habe volgendes gemacht:
1.
Compiler Settings->[SelectedCompiler:"GNU GCC Compiler"]-> kopiert & 
Umbenannt->"OpenCL™"

2.
Compiler Settings->Linker Settings:(rechte Spalte)
-lOpenCL

3.
Compiler Settings->Search Directories->Compiler:
(Anmerkung: ich habe es mit 3 Arten versucht:
C:\Program Files (x86)\AMD APP SDK\3.0\include\CL
und:
C:\Program Files (x86)\AMD APP SDK\3.0\include

4.
Compiler Settings->Search Directories->Linker:
(Anmerkung: ich habe es mit 3 Arten versucht:
C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86_64
und:
C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86

5.
der Text:
"Now you can create a new project which will use our customized compiler 
configuration as compiler and create a new main file in it and copy 
paste the following simple code. This sample just list the names and 
type the OpenCL™ compatible devices on your computer."
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include <stdlib.h>
#include <CL/cl.h>

typedef struct DeviceDesc{
  cl_device_id    deviceId;
  cl_device_type  deviceType;
  char*           deviceTypeString;
  char*           deviceName;
} DeviceDesc;

int main(void)
{
  size_t              i;
  size_t              maxDevices = 5;
  cl_device_id*       deviceIDs = 
(cl_device_id*)malloc(maxDevices*sizeof(cl_device_id));
  cl_platform_id*     platforms = 
(cl_platform_id*)malloc(sizeof(cl_platform_id));
  cl_int              err;
  cl_uint             num_entries = 1;
  cl_uint             available;
  cl_uint             numDevices;
  DeviceDesc*         devices;

  //Get available platforms (we will use the first result, I think most 
of the time we have
  //one platform on personnal computers)
  cl_int result = clGetPlatformIDs(num_entries, platforms, &available);

  err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, maxDevices, 
deviceIDs, &numDevices);

  devices = (DeviceDesc*)malloc(numDevices*sizeof(DeviceDesc));

  for(i=0 ; i<numDevices ; i++)
  {
    devices[i].deviceId = deviceIDs[i];
    size_t actualSize;

    //Getting the device type (processor, graphics card, accelerator)
    result = clGetDeviceInfo(
      deviceIDs[i],
      CL_DEVICE_TYPE,
      sizeof(cl_device_type),
      &devices[i].deviceType,
      &actualSize);

    //Getting the human readable device type
    switch(devices[i].deviceType)
    {
       case CL_DEVICE_TYPE_CPU:
        devices[i].deviceTypeString = "Processor";
        break;
       case CL_DEVICE_TYPE_GPU:
        devices[i].deviceTypeString = "Graphics card";
        break;
       case CL_DEVICE_TYPE_ACCELERATOR:
        devices[i].deviceTypeString = "Accelerator";
        break;
       default:
        devices[i].deviceTypeString = "NONE";
        break;
    }

    //Getting the device name
    size_t deviceNameLength = 4096;
    char* tempDeviceName = (char*)malloc(4096);
    result |= clGetDeviceInfo(
      deviceIDs[i],
      CL_DEVICE_NAME,
      deviceNameLength,
      tempDeviceName,
      &actualSize);
    if(result == CL_SUCCESS){
      devices[i].deviceName = (char*)malloc(actualSize);
      memcpy(devices[i].deviceName, tempDeviceName, actualSize);
      free(tempDeviceName);
    }

    //If an error occured
    if(result != CL_SUCCESS)
    {
      printf("Error while getting device info\n");
      return;
    }
  }

  //And finally we print the information we wanted to have
  for(i=0 ; i<numDevices ; i++){
    printf("Device %s is of type %s\n", devices[i].deviceName, 
devices[i].deviceTypeString);
  }

  //Free memory
  free(deviceIDs);
  free(platforms);
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

und jetzt bekomme ich folgendes als Meldung:

-------------- Build: Debug in test (compiler: OpenCL™)---------------

Skipping file (no compiler program set): main.c
Skipping linking (no linker program set): bin\Debug\test.exe
Nothing to be done (all items are up-to-date).

Anmerkung:
It seems that this project has not been build yet.
Do you want do build it now?

und dieser Dialog kommt dauerhaft wenn ich Ja drücke, und wenn ich Nein 
drücke wird die 2te Zeile gemacht:

-------------- Run: Debug in test (compiler: OpenCL™)---------------

Checking for existence: C:\Work\Pjk\test\bin\Debug\test.exe
Executing: "C:\Work\CodeBlocks/cb_console_runner.exe" 
"C:\Work\Pjk\test\bin\Debug\test.exe"  (in C:\Work\Pjk\test\.)
Process terminated with status -1073741510 (0 minute(s), 5 second(s))

ein leeres Fenster mit keinem Inhalt und das wars ...

von Roland (Gast)


Lesenswert?

Es hat sich erledigt, @ Admin es kann gelöscht werden danke!

von Timmo H. (masterfx)


Lesenswert?

Roland schrieb:
> Es hat sich erledigt, @ Admin es kann gelöscht werden danke!
Nö warum? Schreib doch lieber wie du es gelöst hast bzw. was das Problem 
war und dann kann man den Thread schließen, aber nicht löschen, das 
würde ja keinem in der Zukunft mehr helfen.

von Roland (Gast)


Lesenswert?

@ Timmo H. gute Idee,

habe folgendes gemacht:
1.
AMD APP SDK 3.0.130.135
und
Code::Blocks 13.12
installieren

Folgende Änderungen werden in Code::Blocks durchgeführt!

2.
Compiler Settings->[SelectedCompiler:"GNU GCC Compiler"]-> kopieren &
umbenennen->"OpenCL™"

3.
Compiler Settings->Linker Settings:(rechte Spalte)
-lOpenCL
(ACHTUNG!!! der erste Buchstabe ist ein kleines L)

4.
Compiler Settings->Search Directories->Compiler:Add
C:\Program Files (x86)\AMD APP SDK\3.0\include
(Anmerkung: Dieses Verzeichnis ist davon Abhängig wo man AMD APP SDK 
installiert)

5.
Compiler Settings->Search Directories->Linker:Add
C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86
(Anmerkung: Dieses Verzeichnis ist davon Abhängig wo man AMD APP SDK 
installiert)

Vergesst nicht den Compiler als Standard festzulegen nachdem ihr Ihn 
konfiguriert habt und anschließend auf Ok Quitieren.

6.
neues Projekt -> Consolen Applikation->c .....-> code einfügen und viel 
spass :)

CODE:
(Beinhaltet bereits die Änderung!)
(Anmerkung: Die +++++ Reihe am Anfang und am Ende gehören NICHT zum 
Code!)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <CL/cl.h>

typedef struct DeviceDesc{
  cl_device_id    deviceId;
  cl_device_type  deviceType;
  char*           deviceTypeString;
  char*           deviceName;
} DeviceDesc;

int main(void)
{
  size_t              i;
  size_t              maxDevices = 5;
  cl_device_id*       deviceIDs =
(cl_device_id*)malloc(maxDevices*sizeof(cl_device_id));
  cl_platform_id*     platforms =
(cl_platform_id*)malloc(sizeof(cl_platform_id));
  cl_int              err;
  cl_uint             num_entries = 1;
  cl_uint             available;
  cl_uint             numDevices;
  DeviceDesc*         devices;

  //Get available platforms (we will use the first result, I think most
of the time we have
  //one platform on personnal computers)
  cl_int result = clGetPlatformIDs(num_entries, platforms, &available);

  err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, maxDevices,
deviceIDs, &numDevices);

  devices = (DeviceDesc*)malloc(numDevices*sizeof(DeviceDesc));

  for(i=0 ; i<numDevices ; i++)
  {
    devices[i].deviceId = deviceIDs[i];
    size_t actualSize;

    //Getting the device type (processor, graphics card, accelerator)
    result = clGetDeviceInfo(
      deviceIDs[i],
      CL_DEVICE_TYPE,
      sizeof(cl_device_type),
      &devices[i].deviceType,
      &actualSize);

    //Getting the human readable device type
    switch(devices[i].deviceType)
    {
       case CL_DEVICE_TYPE_CPU:
        devices[i].deviceTypeString = "Processor";
        break;
       case CL_DEVICE_TYPE_GPU:
        devices[i].deviceTypeString = "Graphics card";
        break;
       case CL_DEVICE_TYPE_ACCELERATOR:
        devices[i].deviceTypeString = "Accelerator";
        break;
       default:
        devices[i].deviceTypeString = "NONE";
        break;
    }

    //Getting the device name
    size_t deviceNameLength = 4096;
    char* tempDeviceName = (char*)malloc(4096);
    result |= clGetDeviceInfo(
      deviceIDs[i],
      CL_DEVICE_NAME,
      deviceNameLength,
      tempDeviceName,
      &actualSize);
    if(result == CL_SUCCESS){
      devices[i].deviceName = (char*)malloc(actualSize);
      memcpy(devices[i].deviceName, tempDeviceName, actualSize);
      free(tempDeviceName);
    }

    //If an error occured
    if(result != CL_SUCCESS)
    {
      printf("Error while getting device info\n");
      return 0;
    }
  }

  //And finally we print the information we wanted to have
  for(i=0 ; i<numDevices ; i++){
    printf("Device %s is of type %s\n", devices[i].deviceName,
devices[i].deviceTypeString);
  }

  //Free memory
  free(deviceIDs);
  free(platforms);
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(Anmerkung: Ich bin nicht der Author des Codes,
httb://www.obellianne.fr/alexandre/tutorials/OpenCL/tuto_opencl_codebloc
ks.php
(Anmerkung:httb ->http)

Meine Änderungen am Orginal Code:
#include <string.h>
#include <stdio.h>
.
.
.
return 0;

Wünsche euch viel spaß mit openCL, möge der Code mit euch sein ;)

von Roland (Gast)


Lesenswert?

@ Admin wenn möglich den Lösungspost in den ersten Post verschieben und 
als solved deklarieren für suchende und den Rest löschen.
Danke nochmal Timmo H. für den Hinweis

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.