|
1 | 1 | /*
|
2 | 2 | * Copyright © 2009 CNRS
|
3 |
| - * Copyright © 2009-2020 Inria. All rights reserved. |
| 3 | + * Copyright © 2009-2022 Inria. All rights reserved. |
4 | 4 | * Copyright © 2009-2010 Université Bordeaux
|
5 | 5 | * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
|
6 | 6 | * See COPYING in top-level directory.
|
@@ -323,17 +323,29 @@ hwloc_synthetic_parse_memory_attr(const char *attr, const char **endp)
|
323 | 323 | hwloc_uint64_t size;
|
324 | 324 | size = strtoull(attr, (char **) &endptr, 0);
|
325 | 325 | if (!hwloc_strncasecmp(endptr, "TB", 2)) {
|
326 |
| - size <<= 40; |
| 326 | + size *= 1000ULL*1000ULL*1000ULL*1000ULL; |
327 | 327 | endptr += 2;
|
| 328 | + } else if (!hwloc_strncasecmp(endptr, "TiB", 3)) { |
| 329 | + size <<= 40; |
| 330 | + endptr += 3; |
328 | 331 | } else if (!hwloc_strncasecmp(endptr, "GB", 2)) {
|
329 |
| - size <<= 30; |
| 332 | + size *= 1000ULL*1000ULL*1000ULL; |
330 | 333 | endptr += 2;
|
| 334 | + } else if (!hwloc_strncasecmp(endptr, "GiB", 3)) { |
| 335 | + size <<= 30; |
| 336 | + endptr += 3; |
331 | 337 | } else if (!hwloc_strncasecmp(endptr, "MB", 2)) {
|
332 |
| - size <<= 20; |
| 338 | + size *= 1000ULL*1000ULL; |
333 | 339 | endptr += 2;
|
| 340 | + } else if (!hwloc_strncasecmp(endptr, "MiB", 3)) { |
| 341 | + size <<= 20; |
| 342 | + endptr += 3; |
334 | 343 | } else if (!hwloc_strncasecmp(endptr, "kB", 2)) {
|
335 |
| - size <<= 10; |
| 344 | + size *= 1000ULL; |
336 | 345 | endptr += 2;
|
| 346 | + } else if (!hwloc_strncasecmp(endptr, "kiB", 3)) { |
| 347 | + size <<= 10; |
| 348 | + endptr += 3; |
337 | 349 | }
|
338 | 350 | *endp = endptr;
|
339 | 351 | return size;
|
@@ -802,15 +814,15 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
|
802 | 814 | } else if (hwloc__obj_type_is_cache(type)) {
|
803 | 815 | if (!curlevel->attr.memorysize) {
|
804 | 816 | if (1 == curlevel->attr.depth)
|
805 |
| - /* 32Kb in L1 */ |
| 817 | + /* 32KiB in L1 */ |
806 | 818 | curlevel->attr.memorysize = 32*1024;
|
807 | 819 | else
|
808 |
| - /* *4 at each level, starting from 1MB for L2, unified */ |
| 820 | + /* *4 at each level, starting from 1MiB for L2, unified */ |
809 | 821 | curlevel->attr.memorysize = 256ULL*1024 << (2*curlevel->attr.depth);
|
810 | 822 | }
|
811 | 823 |
|
812 | 824 | } else if (type == HWLOC_OBJ_NUMANODE && !curlevel->attr.memorysize) {
|
813 |
| - /* 1GB in memory nodes. */ |
| 825 | + /* 1GiB in memory nodes. */ |
814 | 826 | curlevel->attr.memorysize = 1024*1024*1024;
|
815 | 827 | }
|
816 | 828 |
|
|
0 commit comments