11// This file is part of BOINC.
2- // http ://boinc.berkeley.edu
3- // Copyright (C) 2016 University of California
2+ // https ://boinc.berkeley.edu
3+ // Copyright (C) 2026 University of California
44//
55// BOINC is free software; you can redistribute it and/or modify it
66// under the terms of the GNU Lesser General Public License
@@ -76,28 +76,22 @@ void read_db() {
7676}
7777
7878PLATFORM* lookup_platform (int id) {
79- unsigned int i;
80- for (i=0 ; i<platforms.size (); i++) {
81- PLATFORM& p = platforms[i];
79+ for (PLATFORM& p: platforms) {
8280 if (p.id == id) return &p;
8381 }
8482 return NULL ;
8583}
8684
8785APP_VERSION* lookup_av (int id) {
88- unsigned int i;
89- for (i=0 ; i<app_versions.size (); i++) {
90- APP_VERSION& av = app_versions[i];
86+ for (APP_VERSION& av: app_versions) {
9187 if (av.id == id) return &av;
9288 }
9389 printf (" missing app version %d\n " , id);
9490 exit (1 );
9591}
9692
9793APP& lookup_app (int id) {
98- unsigned int i;
99- for (i=0 ; i<apps.size (); i++) {
100- APP& app = apps[i];
94+ for (APP& app: apps) {
10195 if (app.id == id) return app;
10296 }
10397 printf (" missing app: %d\n " , id);
@@ -106,9 +100,7 @@ APP& lookup_app(int id) {
106100}
107101
108102HOST_APP_VERSION& lookup_host_app_version (int hostid, int avid) {
109- unsigned int i;
110- for (i=0 ; i<host_app_versions.size (); i++) {
111- HOST_APP_VERSION& hav = host_app_versions[i];
103+ for (HOST_APP_VERSION& hav: host_app_versions) {
112104 if (hav.host_id != hostid) continue ;
113105 if (hav.app_version_id != avid) continue ;
114106 return hav;
@@ -120,16 +112,13 @@ HOST_APP_VERSION& lookup_host_app_version(int hostid, int avid) {
120112 return host_app_versions.back ();
121113}
122114
123- void print_average (AVERAGE& a) {
124- printf (" n %f avg %f\n " , a.n , a.get_avg ()
125- );
115+ void print_average (const AVERAGE& a) {
116+ printf (" n %f avg %f\n " , a.n , a.get_avg ());
126117}
127118
128119void print_avs () {
129- unsigned int i;
130120 printf (" ----- scales --------\n " );
131- for (i=0 ; i<app_versions.size (); i++) {
132- APP_VERSION& av = app_versions[i];
121+ for (const APP_VERSION& av: app_versions) {
133122 if (!av.pfc .n ) continue ;
134123 PLATFORM* p = lookup_platform (av.platformid );
135124 printf (" app %lu vers %lu (%s %s)\n scale %f " ,
@@ -163,7 +152,7 @@ struct RSC_INFO {
163152 nvers_thresh = 0 ;
164153 nvers_total = 0 ;
165154 }
166- void update (APP_VERSION& av) {
155+ void update (const APP_VERSION& av) {
167156 nvers_total++;
168157 if (av.pfc .n > MIN_VERSION_SAMPLES) {
169158 nvers_thresh++;
@@ -177,12 +166,11 @@ struct RSC_INFO {
177166};
178167
179168void scale_versions (APP& app, double avg) {
180- for (unsigned int j=0 ; j<app_versions.size (); j++) {
181- APP_VERSION& av = app_versions[j];
169+ for (APP_VERSION& av: app_versions) {
182170 if (av.appid != app.id ) continue ;
183171 if (av.pfc .n < MIN_VERSION_SAMPLES) continue ;
184172
185- av.pfc_scale = avg/av.pfc .get_avg ();
173+ av.pfc_scale = avg/av.pfc .get_avg ();
186174 PLATFORM* p = lookup_platform (av.platformid );
187175 printf (" updating scale factor for (%s %s)\n " ,
188176 p->name , av.plan_class
@@ -198,17 +186,14 @@ void scale_versions(APP& app, double avg) {
198186// and find the min average PFC for each app
199187//
200188void update_av_scales () {
201- unsigned int i, j;
202189 printf (" ----- updating scales --------\n " );
203- for (i=0 ; i<apps.size (); i++) {
204- APP& app = apps[i];
190+ for (APP& app: apps) {
205191 printf (" app %lu\n " , app.id );
206192 RSC_INFO cpu_info, gpu_info;
207193
208194 // find the average PFC of CPU and GPU versions
209195
210- for (j=0 ; j<app_versions.size (); j++) {
211- APP_VERSION& av = app_versions[j];
196+ for (const APP_VERSION& av: app_versions) {
212197 if (av.appid != app.id ) continue ;
213198 if (strstr (av.plan_class , " cuda" ) || strstr (av.plan_class , " ati" )) {
214199 printf (" gpu update: %lu %s %f\n " , av.id , av.plan_class , av.pfc .get_avg ());
@@ -247,8 +232,6 @@ void update_av_scales() {
247232 accumulate_stats = true ;
248233 }
249234 }
250-
251-
252235 }
253236 printf (" -------------\n " );
254237}
0 commit comments