diff --git a/samples/wrapper/wrapper.cpp b/samples/wrapper/wrapper.cpp index 79e754b641..42ff04c68d 100644 --- a/samples/wrapper/wrapper.cpp +++ b/samples/wrapper/wrapper.cpp @@ -84,6 +84,7 @@ inline void debug_msg(const char* x) { using std::vector; using std::string; int nthreads = 1; +int gpu_device_num = -1; struct TASK { string application; @@ -233,6 +234,7 @@ void str_replace_all(char* buf, const char* s1, const char* s2) { // macro-substitute strings from job.xml // $PROJECT_DIR -> project directory // $NTHREADS --> --nthreads arg if present, else 1 +// $GPU_DEVICE_NUM --> gpu_device_num from init_data.xml, or --device arg // void macro_substitute(char* buf) { const char* pd = strlen(aid.project_dir)?aid.project_dir:"."; @@ -240,6 +242,14 @@ void macro_substitute(char* buf) { char nt[256]; sprintf(nt, "%d", nthreads); str_replace_all(buf, "$NTHREADS", nt); + + if (aid.gpu_device_num >= 0) { + gpu_device_num = aid.gpu_device_num; + } + if (gpu_device_num >= 0) { + sprintf(nt, "%d", gpu_device_num); + str_replace_all(buf, "$GPU_DEVICE_NUM", nt); + } } // make a list of files in the slot directory, @@ -959,6 +969,8 @@ int main(int argc, char** argv) { for (int j=1; j