arrayfire icon indicating copy to clipboard operation
arrayfire copied to clipboard

[Question] Have an array allocation failing w/ errno 103

Open aaronsuydam opened this issue 1 year ago • 2 comments

Hey all,

I have some code that is erroring and i have no idea why.

{    
    // Show available backends
    auto backends = af::getAvailableBackends();
    cout << "Available backends: ";
    if(backends & AF_BACKEND_CPU) cout << "CPU ";
    if(backends & AF_BACKEND_CUDA) cout << "CUDA ";
    if(backends & AF_BACKEND_ONEAPI) cout << "OneAPI ";
    if(backends & AF_BACKEND_OPENCL) cout << "OpenCL ";
    cout << endl;

    my_namespace::methods::af_benchmark_solve_linear_system();
}
void af_benchmark_solve_linear_system()
        {
            // Define the coefficient matrix A (10x10)
            float A_vals[] = 
            {
                2, 3, -4, 1, -5, 7, 2, -6, 8, -1,
                5, -6, 3, 7, -1, 9, 4, 8, 2, -3,
                -3, 5, -7, 9, -4, 6, 1, -2, 3, 5,
                6, 1, -5, 3, -8, 4, 9, 2, -7, -1,
                4, -7, 8, 2, -1, 3, 5, -6, 9, 1,
                -1, 3, 6, -4, 7, -5, 8, 2, -3, 4,
                7, -4, 3, -5, 6, 9, -2, 1, 4, -8,
                8, 6, -9, 1, 3, -7, 5, -2, 1, 6,
                5, -3, 7, -8, 4, 6, -1, 9, 2, -5,
                3, 1, -6, 5, -7, 8, 2, 4, -9, 3
            };

            // Define the right-hand side vector b (10x1)
            float b_vals[] = {15, -12, 10, 20, -5, 18, 25, -7, 14, 8};

            // Create ArrayFire arrays for A and b
            try
            {
                af::array A = af::randu(10, 10, f32);
                af::array b(10, b_vals);
            
                // Solve the linear system
                af::array x = af::solve(A, b);
            }
            catch (af::exception &ex)
            {
                cout << stderr << " ArrayFire error: " << ex.what() << endl;
            }

        }

When it reaches the af:array A = af::randu(...) line, it throws this error:

In function af_err __cdecl af_randu(af_array *, const unsigned int, const dim_t *const, const af_dtype)
In file C:/Users/stef/coding/arrayfire/src/api/c/random.cpp:346


 0# 0x00007FFC025A6E87 in C:\Program Files\ArrayFire\v3\lib\afoneapi.dll
 1# 0x00007FFC0528FDB7 in C:\Program Files\ArrayFire\v3\lib\afoneapi.dll
 2# 0x00007FFC054C8953 in C:\Program Files\ArrayFire\v3\lib\afoneapi.dll
 3# 0x00007FFC054C8BB7 in C:\Program Files\ArrayFire\v3\lib\afoneapi.dll
 4# 0x00007FF7A903A50A in C:\bin\arrayfire_bench.exe
 5# 0x00007FF7A9033A8B in C:\bin\arrayfire_bench.exe
 6# 0x00007FF7A9042F59 in C:\bin\arrayfire_bench.exe
 7# 0x00007FF7A9042E42 in C:\bin\arrayfire_bench.exe
 8# 0x00007FF7A9042CFE in C:\bin\arrayfire_bench.exe
 9# 0x00007FF7A9042FEE in C:\bin\arrayfire_bench.exe
10# 0x00007FFD2598DBE7 in C:\WINDOWS\System32\KERNEL32.DLL
11# 0x00007FFD2647FBEC in C:\WINDOWS\SYSTEM32\ntdll.dll

In function array __cdecl af::randu(const dim4 &, const af::dtype)```

If anyone could help me understand what's going on that would be great. I was testing this library earlier and it was working just fine. Without the pdb files though I don't think I'll be able to get close enough to the exception source to figure this one out.

aaronsuydam avatar Nov 08 '24 03:11 aaronsuydam

Update:

# Link ArrayFire to the executable
target_link_libraries(arrayfire_test ArrayFire::af)

this line in my cmakelists file seems to be the culprit, breaking value is

# Link ArrayFire to the executable
target_link_libraries(arrayfire_test ArrayFire::afoneapi ArrayFire::afcpu ArrayFire::afcuda)

Again, not sure why that might cause an issue? The documentation on this is confusing to follow.

aaronsuydam avatar Nov 08 '24 19:11 aaronsuydam

Hi, I am unable to replicate this. Which version of Arrayfire are you using? Could you paste here the entire output from your program including the error 103 message. Which backend(s) are you using and what is the CPU / GPU that you are using. Thanks

christophe-murphy avatar Nov 21 '24 23:11 christophe-murphy