ADLX icon indicating copy to clipboard operation
ADLX copied to clipboard

Next() is not working

Open DryreL opened this issue 1 year ago • 4 comments

I was planning to get GPUs count.

Created a function:

`int GetGPUsCount() { // Call the function to initialize ADLX if (!InitializeADLX()) { // ADLX initialization failed, return a default value or handle the error return -1; }

// Get GPU list
IADLXGPUListPtr gpus;
ADLX_RESULT res = g_ADLXHelp.GetSystemServices()->GetGPUs(&gpus);

if (ADLX_SUCCEEDED(res))
{
    // Iterate through the list to count GPUs
    int gpuCount = 0;
    while (gpus->Next())
    {
        gpuCount++;
    }

    // Clean up ADLX before returning
    g_ADLXHelp.Cleanup();

    return gpuCount;
}
else
{
    // Handle the error, you might want to log or throw an exception
    std::cerr << "Failed to get GPU list" << std::endl;

    // Clean up ADLX before returning
    g_ADLXHelp.Terminate();

    return -1;
}

} `

But Next() is not available. What should I use?

DryreL avatar Dec 25 '23 10:12 DryreL

Does your system have AMD GPU installed? The GetGPUs will only return the AMD GPU.

ericjunwei avatar Dec 28 '23 02:12 ericjunwei

Does your system have AMD GPU installed? The GetGPUs will only return the AMD GPU.

I personally don't have AMD GPU but my friend has. I'm developing a plugin for Unreal Engine, it will get all hardware informations from the available GPU Brands. AMD is one of them.

I was going to test it on my friend's PC but Next() function is not available. It's not about if I have AMD GPU or not.

I'm not planning to run on my PC, but it must compile succesfully.

DryreL avatar Dec 29 '23 00:12 DryreL

Hi,

To loop through any ADLXList, you can use the Begin() and End() methods.

int gpuCount = 0;

for (adlx_uint itr = gpus->Begin(); itr != gpus->End(); itr++) 
{
    gpuCount++;
}

However, for your example, you could use the Size() method:

adlx_uint gpuCount = gpus->Size();

pedroelir avatar Jul 28 '24 09:07 pedroelir

Hi,

To loop through any ADLXList, you can use the Begin() and End() methods.

int gpuCount = 0;

for (adlx_uint itr = gpus->Begin(); itr != gpus->End(); itr++) 
{
    gpuCount++;
}

However, for your example, you could use the Size() method:

adlx_uint gpuCount = gpus->Size();

Thank you!

DryreL avatar Aug 08 '24 07:08 DryreL