Adding support for reading Environmental variable for samples (#186)

* check if env var set and choose device

* clean up for env var

* app modification

* move getEnvVar function to header

* fork example

* spacing adjust

* review comments

* use hipGetErrorName to throw errors

[ROCm/rocdecode commit: 8ec38d2d24]
Esse commit está contido em:
Lakshmi Kumar
2024-01-17 19:57:31 -08:00
commit de GitHub
commit a186a42593
4 arquivos alterados com 41 adições e 19 exclusões
@@ -1078,3 +1078,15 @@ bool RocVideoDecoder::InitHIP(int device_id) {
HIP_API_CALL(hipStreamCreate(&hip_stream_));
return true;
}
int GetEnvVar(const char *name, int &dev_count) {
char *v = std::getenv(name);
if (v) {
char* p_tkn = std::strtok(v, ",");
while (p_tkn != nullptr) {
dev_count++;
p_tkn = strtok(nullptr, ",");
}
}
return dev_count;
}