Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next() is not working #12

Open
DryreL opened this issue Dec 25, 2023 · 4 comments
Open

Next() is not working #12

DryreL opened this issue Dec 25, 2023 · 4 comments

Comments

@DryreL
Copy link

DryreL commented Dec 25, 2023

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?

@ericjunwei
Copy link
Collaborator

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

@DryreL
Copy link
Author

DryreL commented Dec 29, 2023

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.

@pedroelir
Copy link

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();

@DryreL
Copy link
Author

DryreL commented Aug 8, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants