@@ -33,7 +33,30 @@ static void show_warning(PROJECT* p, const char* name) {
3333 );
3434}
3535
36+ static void modify_usage_avc (
37+ const APP_VERSION_CONFIG &avc, RESOURCE_USAGE &ru
38+ ) {
39+ if (strlen (avc.cmdline )) {
40+ safe_strcpy (ru.cmdline , avc.cmdline );
41+ }
42+ if (avc.avg_ncpus ) {
43+ ru.avg_ncpus = avc.avg_ncpus ;
44+ }
45+ if (avc.ngpus ) {
46+ ru.coproc_usage = avc.ngpus ;
47+ }
48+ }
49+
50+ static void modify_usage_ac (const APP_CONFIG &ac, RESOURCE_USAGE &ru) {
51+ if (!ru.rsc_type ) return ;
52+ ru.coproc_usage = ac.gpu_gpu_usage ;
53+ ru.avg_ncpus = ac.gpu_cpu_usage ;
54+ }
55+
3656// having parsed a project's app_config.xml, put the config into effect
57+ // called:
58+ // on startup and reread config (from check_app_config() below)
59+ // after scheduler RPC to that project (in case got new app versions)
3760//
3861int APP_CONFIGS::config_app_versions (PROJECT* p, bool show_warnings) {
3962 bool showed_notice = false ;
@@ -53,9 +76,16 @@ int APP_CONFIGS::config_app_versions(PROJECT* p, bool show_warnings) {
5376 if (!ac.gpu_gpu_usage || !ac.gpu_cpu_usage ) continue ;
5477 for (APP_VERSION* avp: gstate.app_versions ) {
5578 if (avp->app != app) continue ;
56- if (!avp->resource_usage .rsc_type ) continue ;
57- avp->resource_usage .coproc_usage = ac.gpu_gpu_usage ;
58- avp->resource_usage .avg_ncpus = ac.gpu_cpu_usage ;
79+ modify_usage_ac (ac, avp->resource_usage );
80+ }
81+
82+ // BUDA
83+ //
84+ for (WORKUNIT *wup: gstate.workunits ) {
85+ if (!wup->has_resource_usage ) continue ;
86+ if (wup->project != p) continue ;
87+ if (wup->app != app) continue ;
88+ modify_usage_ac (ac, wup->resource_usage );
5989 }
6090 }
6191 for (const APP_VERSION_CONFIG& avc: app_version_configs) {
@@ -68,20 +98,36 @@ int APP_CONFIGS::config_app_versions(PROJECT* p, bool show_warnings) {
6898 continue ;
6999 }
70100 bool found = false ;
71- const size_t cmdline_len = strlen (avc.cmdline );
72101 for (APP_VERSION* avp: gstate.app_versions ) {
73102 if (avp->app != app) continue ;
74103 if (strcmp (avp->plan_class , avc.plan_class )) continue ;
75104 found = true ;
76- if (cmdline_len) {
77- safe_strcpy (avp->resource_usage .cmdline , avc.cmdline );
105+
106+ // modify the app version's resource usage
107+ //
108+ modify_usage_avc (avc, avp->resource_usage );
109+
110+ // for BUDA, modify the resource usage
111+ // of WUs that use this app version
112+ //
113+ // WU doesn't directly link to app version;
114+ // see if there's a result that links to both
115+ //
116+ for (WORKUNIT *wup: gstate.workunits ) {
117+ wup->ref_cnt = 0 ;
78118 }
79- if (avc.avg_ncpus ) {
80- avp->resource_usage .avg_ncpus = avc.avg_ncpus ;
119+ for (RESULT *rp: gstate.results ) {
120+ if (rp->avp == avp) {
121+ rp->wup ->ref_cnt = 1 ;
122+ }
81123 }
82- if (avc.ngpus ) {
83- avp->resource_usage .coproc_usage = avc.ngpus ;
124+ for (WORKUNIT *wup: gstate.workunits ) {
125+ if (!wup->has_resource_usage ) continue ;
126+ if (wup->ref_cnt == 0 ) continue ;
127+ modify_usage_avc (avc, wup->resource_usage );
84128 }
129+ // don't break here; it's possible that multiple app versions
130+ // have the same app and plan class
85131 }
86132 if (!found) {
87133 msg_printf (p, MSG_USER_ALERT,
0 commit comments