Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

A brief history of Mac numeric processing

By: hoakley
4 January 2025 at 16:00

It might seem extraordinary today, but the first Macs with Motorola 68000 processors couldn’t add two floating point numbers directly in their CPU. As with other early processors, they handled integers, not floating point, and that’s one reason why many features such as display coordinates started off using integers rather than floating point as they do today.

Of course the Mac and other computers could perform floating point calculations, but that required the use of maths routines in software libraries. Others had been implementing floating point support in hardware: for example, Intel started developing its own maths coprocessor the 8087 in 1977, and that became available to accompany its 8086 processor, but at that time Motorola didn’t have any equivalent.

68K Macs

Apple hired a young mathematician to define and implement what became known as the Standard Apple Numerics Environment or SANE, for Apple II, III, Lisa and Mac product lines, and it was SANE that formed the basis for Motorola’s 68881 maths coprocessor for its 68020 CPU in 1984. At the same time, the IEEE was standardising floating point maths for computing, and in 1985 published its first version of IEEE 754.

SANE was built into the first Mac 64K ROM, and when Macs started to come with 68020 CPUs and 68881 coprocessors, in the Macintosh II of 1987, they ran their floating point routines on the 68881 or its successor the 68882. In 1991, the first Quadra came with a Motorola 68040 and its integrated floating point unit, although as late as 1995 Apple was still releasing new Macs that lacked any hardware support for floating point maths. The most complete description of SANE is in a printed account published by Addison-Wesley, the second edition dating from 1988.

Power Macs

The change to PowerPC processors in 1994 brought an end to SANE, replacing it with PowerPC Numerics, which differed in many of its details. Floating point support in PowerPC CPUs included additional instructions to support Apple’s new standard. The period of transition was covered by providing SANE for backward compatibility with apps that had been built for Motorola 68K processors, and encouraging developers to rebuild their apps to use the PowerPC’s new Numerics. Tom Pittman and John Neil produced and marketed PowerFPU, a control panel for Power Macs, that ran 68K floating point code in emulation.

From 1996, the AIM Alliance of Apple, IBM and Motorola developed extensions to the PowerPC instruction set to support vector processing. Known variously as AltiVec, VMX for Vector Multimedia Extension, and Apple’s Velocity Engine, it was used to accelerate QuickTime and Quartz, when it was introduced in Mac OS X. Those extensions handle both integer and floating point in registers that are 128-bit wide to pack in multiple values for its operations. Velocity Engine was supported by Power Macs with G4 and G5 processors, from 1999 onwards.

Intel Macs

When Macs changed architecture to use Intel CPUs, those had integral floating point support, including x87 maths co-processor emulation and Intel’s Streaming SIMD Extensions, SSE, providing a replacement for features in the PowerPC. From 2003, in Mac OS 10.3 Panther, Apple had collected its more advanced numerical and vector support into the Accelerate framework, covering signal processing, image processing, linear algebra with BLAS/LAPACK, vector maths and more.

The transition to Intel wasn’t as seamless as might have appeared though, because of differences that might at first look subtle. For instance, PowerPC floating point support included a single, fused operation to multiply and add, but Intel CPUs performed the operations separately, which could accumulate additional rounding error. Apple warned “that in cases involving catastrophic cancellation, this may give results that are vastly different after the addition or subtraction has completed.”

As Intel Macs developed, they acquired increasingly capable GPUs that offered an alternative for some floating point calculations. OpenCL was introduced in 2009 to facilitate this, and in 2015, with OS X 10.11 El Capitan, Apple added support for its own GPU programming using the Metal API. That has evolved since, with Metal 2 introduced in macOS 10.13 High Sierra, and subsequent enhancements.

Apple silicon

From the first M1 chip, Apple silicon has put floating point performance to the fore. All the old variables that had originally been coded as integers have now become floating point, requiring fast and accurate scalar, vector and matrix support. CPU cores, even Efficiency cores, include extensive scalar instructions, with Arm’s NEON vector processing. GPUs support Metal 3, and matrix operations are catered for in a dedicated neural engine and an undocumented matrix coprocessor, the AMX. The latest M4 chip adds support for Arm’s SME matrix extensions in its ARMv9.2-A instruction set, although those are thought to be executed by the AMX.

While most of those are supported directly, access to the neural engine and (prior to the M4) the AMX coprocessor have been limited. It’s believed that appropriate functions in the Accelerate and related frameworks use whatever hardware is most appropriate.

Floating point calculations, often using very large matrices, are a key part of modern neural networks and both Machine Learning and Apple/Artificial Intelligence. Apple added support for a new floating point format, bfloat16, to Metal in 2023, and in its CPU core instruction set with the M2.

In the 40 years since the 128K Mac, crunching numbers has come a long way, thanks to Apple’s dedicated teams of mathematician-engineers.

Floating point formats

One of the eternal problems when working with floating point numbers in hex is their encoding. Converting IEEE 754 hex format into decimal expressed in engineering notation is fairly arcane. My free Mints includes a floating point explorer, to convert between 32- and 64-bit floating point and decimal engineering/scientific formats.

mints1183

References

PowerFPU, a brief account by Tom Pittman
IEEE 754 at Wikipedia
Inside Macintosh: PowerPC Numerics on the Internet Archive
Velocity Engine on the Internet Archive
SSE Performance Programming and the early Accelerate framework, on the Internet Archive
Accelerate framework (current)
Metal calculations on a GPU (current)

Alon Alexander Is Denied Bail in Sex Trafficking Case

Mr. Alexander’s brother, Oren Alexander, was granted a hearing extension by a judge in Miami. A third brother, Tal Alexander, was denied bail on related charges in December.

© Pool photo by Matias J Ocner

Alon Alexander, right, and his brother, Oren Alexander, attend an initial bond hearing in Miami on Dec. 13, a day after they entered not guilty pleas to state charges of sexual battery.

乳腺癌第十五年复查 2024年10月25日,星期五

By: 10year
26 October 2024 at 03:44
今天去伦敦医院进行一年一度的乳腺癌复查。为了看伦敦秋景,我起了个大早(7点到伦敦),暴走了3万多步,从火车站一 […]

使用 Apple Watch S8 的一些体验

By: Lucky
28 November 2022 at 09:55

以前一直想拥有一款 Apple Watch,但因为种种原因总是错过,或者说没想好自己到底需不需要这一块表。Apple Watch S5 的处理器只是换了马甲,和 S4 的一样。然后 S6 的时候没咋关注,当时更喜欢 Garmin 这种 Hardcore 一点的表,等到 S7 的时候有传闻说外观会有大的改变,和 iPhone 12 一样是直角平整边框,结果也没有。直到今年的 Apple Watch S8 还是没有大的改变,估计这下外观固定了,估计好多年不会变,让我遗憾的是用的处理器自从 Apple Watch S6 以来就没有更换过,可能明年就有大幅度升级了吧,也罢,不等了,入手。

选择哪一款

今年还有 Apple Watch SE2 和 Apple Watch Ultra,前者是入门款,没有 Always On Display,用的元件都是库存老款,直接 pass。后者主打极限户外,但是说实话,这售价比 Garmin 的一些户外表还便宜,续航啥的也差一截,为了穿搭好看我还是选择了 Apple Watch S8。不锈钢款性价比太低,加一点钱可以上 Apple Watch Ultra,就选择铝金属款。

这一代尺寸和上一代 S7 一模一样,我选择了 45mm 的表盘尺寸,差不多手腕的宽度,适合我。然后就是选择表带,

其中,铝金属版本的编制单圈表带较其他款要贵 ¥400。我选择了 Nike 回环式运动表带,就是以前的 Nike 特别版。

选择了这个「雪峰白配黑色

经常用的功能

  1. 睡眠监测

    大致还是比较准确的,以前有很多第三方软件可以用,但是今年的 watchOS 9 自带的「睡眠」很不错。睡眠数据在 iPhone 的「健康」中查看。

    可以知道自己睡眠其实很短啦……提醒自己早睡,起床的手腕震动功能很不错,没有闹铃那么夺命。

  1. 站立提醒

    这是我最需要的核心功能之一,在每个钟头的五十分时候会提醒站立一分钟

  2. 体能训练

    里面有几十种运动模式,对于我记录拉伸、核心训练非常有用,不用自己盲算消耗了多少卡路里

  3. 计时器(倒计时)

    配合体能训练就不用 iPhone 计时了

  4. 洗手提示

    时常保持卫生,要洗足 20 秒哦

  5. 歌曲切换

    在开车,骑车时候尤其有帮助,可以滚动侧边表冠来调节音量大小。一键切歌,比在方向盘,中控台切歌方便许多

  6. 消息提示

    有时候 iPhone 揣在兜里不是那么方便拿出来看,这个就很方便了。但是消息过多也是种负担,需要自己斟酌

  7. 指南针

    把这个功能放在表盘上,就能随时知道朝向的方向,我就是随时想知道方位

  8. 心率监测

    耐力运动员很有必要知道自己的静息心率水平,时常测一下

  9. 呼叫 iPhone

找不到 iPhone 的时候按住「呼叫 iPhone」按钮,iPhone 的闪光灯还会闪烁

外观

基本上只要不是出席穿正装的场合,Apple Watch 换一下表带都能佩戴,不同的表带搭配不同的着装,兼容性真的太好了,我目前用着三款表带。

这个虽然叫做 Nike 回环式运动表带,但其实运动时候佩戴并不如硅胶表带适合,原因无他,不好清理,清水冲洗后很难干。但是可调节尺寸佩戴还是很舒服的。

单圈编制-橄榄绿

个人觉得单圈编制表带是最适合穿搭的,但是舒适度会差一点,因为不能调节尺寸,太紧勒着难受,太松又不贴合。不适合运动时候佩戴。

雪峰白配黑色 Nike 运动表带

清洗很方便

这一款 Nike 运动表带是我最喜欢在运动时候戴的,硅胶材质,出了汗水直接冲洗就可以了,很省心。

遗憾

值得一提的是,国行 Apple Watch 没有「对讲机」功能。因为国行 iPhone 阉割了 FaceTime Audio,即 Facetime 的语音通话功能。由于 FaceTime Audio 属于 VoIP 通信,通俗来讲就是网络电话,内地还未开放对民营企业 VoIP 的政策。

结尾

作为在可穿戴智能设备,Apple Watch 系列在中高端市场占据绝对优势,和其生态的强大密不可分,从辅助健康的角度来说他做的已经很好了,如果你买了表不怎么运动也无关紧要,谁说买了卡西欧就一定要运动是不,就是期待未来 Apple 能给这个真正的「掌上」设备带来更多有想象力的功能。

彩蛋:表盘

表盘设置为「加州」,顶部子表盘选择,字母图案,关闭底部子表盘。然后在 iPhone - 时间-手表 - Monogram(字母组合),改成 Rolex 就可以获得一款全新劳力士啦(

同理,也可以每天获得一款新的 Patek Philippe 或者你喜欢的表啦~

❌
❌