QT und Intel MKL Library

Alles rund um die Programmierung mit Qt
Antworten
stardust5383
Beiträge: 28
Registriert: 31. Oktober 2009 10:36

QT und Intel MKL Library

Beitrag von stardust5383 »

Hallo zusammen,

entwickele für meine Studienarbeit eine Qt-Anwendung, die den Intel COmpiler für EMT64 und die Intel MKL (Math Kernel Library) verwendet. Da ich in Qt und C++ noch relativ neu bin, war ich froh, dass ich jetzt den icc-64 compiler mit Qt am laufen habe.

Allerdings habe ich bei der Integration der Intel MKL noch große Probleme.

Folgende Kopfzeile habe ich definiert:

Code: Alles auswählen

#include <QtCore/QCoreApplication>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <mkl_dfti.h>
#include "/opt/intel/Compiler/11.1/059/mkl/examples/dftc/source/mkl_dfti_examples.h"
Starte ich so den Kompiliervorgang, erhalte ich jede Menge

Code: Alles auswählen

undefined reference to '...'
Binde ich über die .pro Datei die passenden Librarys ein mit

Code: Alles auswählen

LIBS += -L/opt/intel/Compiler/11.1/059/mkl/lib/em64t -llibmkl_core
erhalte ich die Meldung

Code: Alles auswählen

ld: cannot find -llibmkl_core
Ich bin mit meinem Latein am Ende. Hat irgendeiner einen Tip für mich, was ich falsch machen könnte? Die Librarys liegen korrekt im angegeben Verzeichnis sowohl als .so als auch als .a

Gruß
Andreas
ChMaster
Beiträge: 252
Registriert: 23. Februar 2005 14:44
Wohnort: RP -> Alzey
Kontaktdaten:

Re: QT und Intel MKL Library

Beitrag von ChMaster »

stardust5383 hat geschrieben:Hallo zusammen,

Code: Alles auswählen

...
#include "/opt/intel/Compiler/11.1/059/mkl/examples/dftc/source/mkl_dfti_examples.h"
Sowas sieht man ungern. :) Ich würd es über die Projektdatei von Qt lösen. In etwa so:

Code: Alles auswählen

DEPENDPATH += /opt/intel/Compiler/11.1/059/mkl/examples/dftc/source
INCLUDEPATH += /opt/intel/Compiler/11.1/059/mkl/examples/dftc/source
Dann kannst du auch dies verwenden:

Code: Alles auswählen

#include "mkl_dfti_examples.h"
Versuch es mal damit. Dann dürfte er die Bibliothek finden.

Code: Alles auswählen

LIBS += -L/opt/intel/Compiler/11.1/059/mkl/lib/em64t -lmkl_core 
ChMaster
------------ Projekte------------
DBoxFE
DMS
First4 (Plugin-Develper)
stardust5383
Beiträge: 28
Registriert: 31. Oktober 2009 10:36

Beitrag von stardust5383 »

Hi ChMaster,

erst einmal vielen Dank für Deine schnelle Antwort.
Ich habe das so eingepflegt, wie Du mir geschrieben hast, erhalte jetzt auch keine Fehlermeldung mehr das er was nicht findet, dafür aber noch jede Menge undefined reference Fehler.

Ich poste einfach mal den Code, den ich zusammen kopiert habe (Anhand eines Beispiels aus der Intel MKL). Das Beispiel ist zwar C-Code, sollte aber doch meines Wissens in c++ genau so ausgeführt werden?!

Code: Alles auswählen

#include <QtCore/QCoreApplication>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "mkl_dfti.h"
#include "mkl_dfti_examples.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    mkl_double_complex* x_in;
    mkl_double_complex* x_exp;

    DFTI_DESCRIPTOR_HANDLE hand = 0;
    MKL_LONG n;
    MKL_LONG Status;
    double Scale;

    double maxerr;
    double eps = DOUBLE_EPS;
    int failure = 0;

    /*
    **  Read input data from input file
    **  n - size of transform
    */
    if (read_data_file_1d(argc, argv, &n)) {
        qDebug(" TEST FAILED : Read input data from input file\n");
        return 1;
    }

    if (LEGEND_PRINT) {
        qDebug("\n\n COMPLEX_1D_DOUBLE_EX1\n");
        qDebug(" Forward-Backward 1D complex transform for double precision data\n\n");
        qDebug(" Configuration parameters:\n\n");
        qDebug(" DFTI_FORWARD_DOMAIN = DFTI_COMPLEX\n");
        qDebug(" DFTI_PRECISION      = DFTI_DOUBLE\n");
        qDebug(" DFTI_DIMENSION      = 1\n");
        qDebug(" DFTI_LENGTHS        = %d\n", n);
        qDebug(" DFTI_PLACEMENT      = DFTI_INPLACE\n");
        qDebug(" DFTI_FORWARD_SCALE  = 1.0\n");
        qDebug(" DFTI_BACKWARD_SCALE = 1.0/n\n\n");
    }

    /*
    **  Allocate array for input data
    */
    x_in  = (mkl_double_complex*)malloc(2*n*sizeof(double));
    x_exp = (mkl_double_complex*)malloc(2*n*sizeof(double));

    /*
    **  Initialize x_in and copy to expected x_exp
    */
    init_input_and_expected_vectors_z(x_in, x_exp, n);

    if (ADVANCED_DATA_PRINT) {
        qDebug(" INPUT vector X_IN\n");
        print_vector_z( x_in, n);
    }

    /*
    **  Create DFTI descriptor for 1D double precision transform
    */
    Status = DftiCreateDescriptor(&hand, DFTI_DOUBLE, DFTI_COMPLEX, 1, n);
    if (! DftiErrorClass(Status, DFTI_NO_ERROR)) {
        dfti_example_status_print(Status);
        qDebug(" TEST FAILED : DftiCreateDescriptor(&hand, DFTI_DOUBLE,...\n");
        failure++;
        goto FREE_ARRAYS;
    }

    /*
    **  Commit DFTI descriptor
    */
    Status = DftiCommitDescriptor(hand);
    if (! DftiErrorClass(Status, DFTI_NO_ERROR)) {
        dfti_example_status_print(Status);
        qDebug(" TEST FAILED : DftiCommitDescriptor(hand)\n");
        failure++;
        goto FREE_DESCRIPTOR;
    }

    /*
    **  Compute Forward transform
    */
    qDebug("\n Compute DftiComputeForward\n\n");
    Status = DftiComputeForward(hand, x_in);
    if (! DftiErrorClass(Status, DFTI_NO_ERROR)) {
        dfti_example_status_print(Status);
        qDebug(" TEST FAILED : DftiComputeForward(hand, x_in)\n");
        failure++;
        goto FREE_DESCRIPTOR;
    }

    if (ADVANCED_DATA_PRINT) {
        qDebug(" Forward result vector X_IN\n");
        print_vector_z( x_in, n);
    }

    /*
    **  Set Scale number for Backward transform
    */
    Scale = 1.0/(double)n;
    qDebug("\n DFTI_BACKWARD_SCALE  = 1/n\n");

    Status = DftiSetValue(hand, DFTI_BACKWARD_SCALE, Scale);
    if (! DftiErrorClass(Status, DFTI_NO_ERROR)) {
        dfti_example_status_print(Status);
        qDebug(" TEST FAILED : DftiSetValue(hand, DFTI_BACKWARD_SCALE, Scale)\n");
        failure++;
        goto FREE_DESCRIPTOR;
    }

    /*
    **  Commit DFTI descriptor
    */
    Status = DftiCommitDescriptor(hand);
    if (! DftiErrorClass(Status, DFTI_NO_ERROR)) {
        dfti_example_status_print(Status);
        qDebug(" TEST FAILED : DftiCommitDescriptor(hand)\n");
        failure++;
        goto FREE_DESCRIPTOR;
    }

    /*
    **  Compute Backward transform
    */
    qDebug("\n Compute DftiComputeBackward\n\n");
    Status = DftiComputeBackward(hand, x_in);
    if (! DftiErrorClass(Status, DFTI_NO_ERROR)) {
        dfti_example_status_print(Status);
        qDebug(" TEST FAILED : DftiComputeBackward(hand, x_in)\n");
        failure++;
        goto FREE_DESCRIPTOR;
    }

    if (ADVANCED_DATA_PRINT) {
        qDebug(" Backward result vector X_IN\n");
        print_vector_z( x_in, n);
    }

    /*
    **  Check result
    */
    maxerr = check_result_z(x_in, x_exp, n);

    if (ACCURACY_PRINT)
        qDebug("\n Accuracy = %g\n\n", maxerr);

    if (maxerr < eps) {
        qDebug(" TEST PASSED\n");
    } else {
        qDebug(" TEST FAILED\n");
        failure++;
    }

    /*
    **  Free DFTI descriptor
    */
FREE_DESCRIPTOR:
    Status = DftiFreeDescriptor(&hand);
    if (! DftiErrorClass(Status, DFTI_NO_ERROR)) {
        dfti_example_status_print(Status);
        qDebug(" TEST FAILED : DftiFreeDescriptor(&hand)\n");
        failure++;
    }

    /*
    **  Free arrays for input and expected data
    */
FREE_ARRAYS:
    free(x_in);
    free(x_exp);

    if (failure)
        return 1;

    qDebug("\n END OF TEST\n");

    return a.exec();
}
Als Fehlermeldung erhalte ich u.a. (Fehler ist immer gleich, nur mit den anderen Funktionen):

Code: Alles auswählen

undefined reference to `read_data_file_1d(int, char**, long*)'
Ist vielleicht alles ein ziemliches Anfängerproblem, aber ich bin am Ende mit meinem Latein, will aber irgendwie endlich mal den Einstieg finden :)

gruß
Andreas
ChMaster
Beiträge: 252
Registriert: 23. Februar 2005 14:44
Wohnort: RP -> Alzey
Kontaktdaten:

Beitrag von ChMaster »

Code: Alles auswählen

undefined reference to `read_data_file_1d(int, char**, long*)'
Solch eine Meldung sagt nur aus, dass er die Refernece zu dieser Funktion nicht finden kann. Es reicht anscheinend nicht nur die "mkl_core" zu Linken sondern da fehlen noch andere Bibliotheken.
Schau mal in dem Verzeichnis nach ob da noch andere darin liegen. Wenn ja, link mal alle gegen deine Anwendung und kommentiere alle nach einander aus. Das erreichst du in dem du vor LIBS += ... eine Raute (#) setzt.

z.B.:

Code: Alles auswählen

#LIBS += -L/opt/intel/Compiler/11.1/059/mkl/lib/em64t -lmkl_core
Und in welcher Header-Datei ist "read_data_file_1d" definiert?
ChMaster
------------ Projekte------------
DBoxFE
DMS
First4 (Plugin-Develper)
Antworten