Skip to content

Problem Converting Code Using std::vectors to MLIR #437

Description

@petecao

I am trying to compile a simple gather function using vectors for data storage using the compilation flag

cgeist $1 -O0 -g -fopenmp -S -o $fileBase.affine.mlir -I/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 \
    -I/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 \
    -I/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward \
    -I/home/$USER_NAME/$PROJECT_NAME/build/lib/clang/18/include \
    -I/usr/local/include \
    -I/usr/include -D$4

The function that I'm trying to compile is

#include <iostream>
#include <vector>

#pragma scop
void gather_vec(std::vector<int> &a,
            std::vector<int> &b,
            std::vector<int> &idx) {
    for (size_t i = 0; i < idx.size(); ++i) {
        a[i] = b[idx[i]];
    }
}

int main() {
    std::vector<int> a; 
    std::vector<int> b = {1, 2, 3, 4};
    std::vector<int> idx = {3, 2, 1, 0};

    gather_vec(a, b, idx);

    // verification
    for (size_t i = 0; i < a.size(); ++i) {
        std::cout << "a[" << i << "] = " << a[i] << "\n";
    }

    return 0;
}

and when I run the cgeist command, I get some cleanup not handled and this error before printing out the intermediate MLIR. I have also attached the whole log.

cgeist_error.txt

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions