Unknown CPU type reported for Apple M1 #87728

Closed
opened 2021-04-22 21:18:58 +02:00 by Christian Baars · 7 comments

System Information
Operating system: macOS Big Sur 11.2.3
Graphics card: built-in

Blender Version
Broken: every

The CPU brand string is not recognized and an "Unknown CPU" is reported.

The usage of 'sysctlbyname' should be future proof.

For me the following solution works on Intel and Apple Silicon Macs. In intern/cycles/util/util_system.cpp change from line 167:

string system_cpu_brand_string()
{
#if !defined(WIN32) && !defined(__x86_64__) && !defined(__i386__) && !defined(__APPLE__)
  FILE *cpuinfo = fopen("/proc/cpuinfo", "r");
  if (cpuinfo != nullptr) {
    char cpuinfo_buf[513] = "";
    fread(cpuinfo_buf, sizeof(cpuinfo_buf) - 1, 1, cpuinfo);
    fclose(cpuinfo);

    char *modelname = strstr(cpuinfo_buf, "model name");
    if (modelname != nullptr) {
      modelname = strchr(modelname, ':');
      if (modelname != nullptr) {
        modelname += 2;
        char *modelname_end = strchr(modelname, '\n');
        if (modelname_end != nullptr) {
          *modelname_end = '\0';
          return modelname;
        }
      }
    }
  }
#elif defined(__APPLE__)
    char modelname[512];
    size_t bufferlen = 512;
    sysctlbyname("machdep.cpu.brand_string",&modelname,&bufferlen,NULL,0);
    return modelname;
#else
  char buf[49] = {0};
  int result[4] = {0};

  __cpuid(result, 0x80000000);

  if (result[0] != 0 && result[0] >= (int)0x80000004) {
    __cpuid((int *)(buf + 0), 0x80000002);
    __cpuid((int *)(buf + 16), 0x80000003);
    __cpuid((int *)(buf + 32), 0x80000004);

    string brand = buf;

    /* make it a bit more presentable */
    brand = string_remove_trademark(brand);

    return brand;
  }
#endif
  return "Unknown CPU";
}

I am sorry, if this is the wrong way to make a pull request.

Best regards,
Christian Baars

**System Information** Operating system: macOS Big Sur 11.2.3 Graphics card: built-in **Blender Version** Broken: every The CPU brand string is not recognized and an "Unknown CPU" is reported. The usage of 'sysctlbyname' should be future proof. For me the following solution works on Intel and Apple Silicon Macs. In intern/cycles/util/util_system.cpp change from line 167: ``` string system_cpu_brand_string() { #if !defined(WIN32) && !defined(__x86_64__) && !defined(__i386__) && !defined(__APPLE__) FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); if (cpuinfo != nullptr) { char cpuinfo_buf[513] = ""; fread(cpuinfo_buf, sizeof(cpuinfo_buf) - 1, 1, cpuinfo); fclose(cpuinfo); char *modelname = strstr(cpuinfo_buf, "model name"); if (modelname != nullptr) { modelname = strchr(modelname, ':'); if (modelname != nullptr) { modelname += 2; char *modelname_end = strchr(modelname, '\n'); if (modelname_end != nullptr) { *modelname_end = '\0'; return modelname; } } } } #elif defined(__APPLE__) char modelname[512]; size_t bufferlen = 512; sysctlbyname("machdep.cpu.brand_string",&modelname,&bufferlen,NULL,0); return modelname; #else char buf[49] = {0}; int result[4] = {0}; __cpuid(result, 0x80000000); if (result[0] != 0 && result[0] >= (int)0x80000004) { __cpuid((int *)(buf + 0), 0x80000002); __cpuid((int *)(buf + 16), 0x80000003); __cpuid((int *)(buf + 32), 0x80000004); string brand = buf; /* make it a bit more presentable */ brand = string_remove_trademark(brand); return brand; } #endif return "Unknown CPU"; } ``` I am sorry, if this is the wrong way to make a pull request. Best regards, Christian Baars

Added subscriber: @Staars

Added subscriber: @Staars
Member

Added subscriber: @Alaska

Added subscriber: @Alaska
Member

The official method for submitting a patch can be found on this site:
https://wiki.blender.org/wiki/Process/Contributing_Code

I would personally go down the route of creating a diff file which is described on this site: https://wiki.blender.org/wiki/Tools/CodeReview#Upload_a_Diff
Then to submit it, just go to https:*developer.blender.org/ and select Submit code (shown in image below), upload the diff file, give it a title, add it to the blender repository, and add reviewers (You'll probably find the best people to review this patch in the task #78710, however it may be better to ask over on https:*blender.chat/channel/blender-coders). Following that, go through the review process there.

image.png

One thing I'd like to point out first is are you able to give the ARM version of Blender a try to see if it resolves this issue without the patch you've provided? It's available at https://www.blender.org/download/
I'm sorry, I don't have a M1 Mac and so can't test this.

The official method for submitting a patch can be found on this site: https://wiki.blender.org/wiki/Process/Contributing_Code I would personally go down the route of creating a diff file which is described on this site: https://wiki.blender.org/wiki/Tools/CodeReview#Upload_a_Diff Then to submit it, just go to https:*developer.blender.org/ and select `Submit code` (shown in image below), upload the diff file, give it a title, add it to the blender repository, and add reviewers (You'll probably find the best people to review this patch in the task #78710, however it may be better to ask over on https:*blender.chat/channel/blender-coders). Following that, go through the review process there. ![image.png](https://archive.blender.org/developer/F10033401/image.png) One thing I'd like to point out first is are you able to give the ARM version of Blender a try to see if it resolves this issue without the patch you've provided? It's available at https://www.blender.org/download/ I'm sorry, I don't have a `M1` Mac and so can't test this.

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Christian Baars self-assigned this 2021-04-23 15:58:51 +02:00

Thank you, I will try this out.

As there is no ARM version for download (that I am aware of), I was referring to self compiled versions (>2.93).

For me this task is resolved.

Thank you, I will try this out. As there is no ARM version for download (that I am aware of), I was referring to self compiled versions (>2.93). For me this task is resolved.
Member

In #87728#1151111, @Staars wrote:
Thank you, I will try this out.

As there is no ARM version for download (that I am aware of), I was referring to self compiled versions (>2.93).

Sorry, I gave you the wrong link. The ARM version can be downloaded from here: https://builder.blender.org/download/

> In #87728#1151111, @Staars wrote: > Thank you, I will try this out. > > As there is no ARM version for download (that I am aware of), I was referring to self compiled versions (>2.93). Sorry, I gave you the wrong link. The ARM version can be downloaded from here: https://builder.blender.org/download/

Thank You, this does the same, like the self compiled version.
I addressed this topic here: https://developer.blender.org/D11061

This should will be fixed, one way or another.

Thank You, this does the same, like the self compiled version. I addressed this topic here: https://developer.blender.org/D11061 This should will be fixed, one way or another.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#87728
No description provided.