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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user