EC2 Instances and Vector Programming

I’ve been experimenting with various techniques for vector/SIMD programming in C/C++ and Python (for code generation) using Intel/AMD AVX-512 processors and ARM Neon processors. The performance of various CPUs turned out to be interesting.

I used an EC2 c8i instance for one set of AVX.

For NEON, I used an EC2 t4g instance, an AppleM4, and a Raspberry Pi 5 as well.

All 4 datasets were using the same C++ code employing the std::experimental::native_simd types.

I was kind of surprised at the results.

The AVX wasn’t really a surprise, since its vector registers are 512 bits wide and NEON’s are only 128 bits wide.

I was impressed by the Apple’s performance but I found the Amazon Graviton 2 only doing as well as a Raspberry Pi somewhat disappointing.

Source code: https://github.com/AndrewOfC/vector_reduction


Related discussions:

Is there a way to find out who and if anyone is logged into an EC2 instance (windows?)
Some help with chef in EC2 windows instances and bootstrapping.
EC2 Equivalent in Terms of Real Life CPU?
How do you address SSH keypair management for EC2?
Running multiple sites from EC2
Amazon EC2 with Hadoop is 4 times more expensive than running on our own cluster (crosspost from r/programming)
EC2 EBS instance outgoing bandwidth any good for gaming?
What's the best way to create "worker" ec2 queue on AWS?
Individual DB dumps in RDS
Can NOT work out spot-instance EC2 pricing...
How do i set or get the password of an amazon machine image?
How do I perform incremental backup on AWS RDS (MySQL)?
Any AWS system architect associate test dump?
AWS C4 Instances now available
What back-off strategy do AWS clients use for retrying a request when maxRetries is set to a number greater than 0?
[re:Invent announcement] Rent a rack on EC2
AWS Diagrams - automake?
Questions about Lambda
Can't ssh from one (public) ec2 instance to another (private) one
New instance EBS volume creation time <=> AMI snapshot size
AWS silently decreased EC2 limits to less than running instance number
Do I need to reboot EC2 to get new route table to work?
Sharing my Key pem with hired developer. What kind of security tips I have take into considerations?
Query regarding MS SQL EC2 instance, and putting Temp DBs on the instance stores
Backup solution + snapshots?
What is the best way to patch Linux server?
Windows Anti-Malware kills performance?
How to manage users/groups on AWS Microsoft AD from a non-windows shop?
EC2 Tomcat
Ec2 Instance deleted?!
Unauthorized access to my account, huge bill
AWS announces per-second billing for EC2 instances
Looking for a way to automate AMI sharing
Were there any changes to EC2 instance startup today?
EC2 SSL Freezing
View all deployed services in multiple organizations from one “dashboard”?
Download EC2 image?
SFTP on AWS?
Quality of EC2 instances?
EC2 Instance profiles using expired credentials
Network Load Balancers observations
Region must be actively set from code running in EC2?
Trying to get a website running on an ec2 instance
Seeking help using Parameter Store to hydrate environment variables
Running Program from Task Scheduler on EC2 Instance?
EC2 hardware retirement question.
Quickly renaming 10s of millions of files in S3?
Ec2 high latency/unreachable
SQL error in front-end and back-end.
Question about spot instances, termination warning?
Best to transfer precomputed data or re-compute it on EC2 ?
Got a huge bill, trying to understand why
Anyone using Qubole?
Is it worth it to host a Wordpress on an ec2?
CloudFormation - Create and Verify ACM Certificate using DNS
Application not connecting from Workspace to EC2 SQL
What are some useful EC2 tags?
li - A small tool to quickly find information on EC2 instances
Hibernate r4.4xLarge EC2 (122GB RAM)
EC2 is running but stops responding after few hours
EC2 Fleet with Custom AMI
Where can I find AWS Sample architectures?
Convert EC2 Nginx using RDS to Beanstalk
SSH between two EC2 instances?
$ marks the spot: saving a ton with EC2 Spot Fleet - We reduced by over 60% the EC2 instance cost of our 1000+ node globally-distributed log-producing application by migrating it entirely to EC2 Spot Fleet.
How does the Amazon Web Services (AWS) Charges/Bills?
Simple Pricing API for AWS [Feedback]
Desperate: We bought Reserve Instance EC2 contracts (partial upfronts) and the intended project has now been cancelled. Are we stuck paying $2k+/month?
What's the best way to monitor security groups and instances for unsafe permissions?
aws-ls
Snowball questions
Is there an open-source alternative to AWS Batch that I could run as a layer on top of ECS?
Pro Tip: If you're using Ubuntu Bionic 18.04 image for your EC2 instances and when you run 'apt -upgrade', you'll need to choose "Install package manager's version" option on the prompt or you could kiss your instance goodbye.
T3a coming soon?
AWS Architecture Icons Updated
Cloud Custodian - What's your setup?
Seems we will have centralised host keys and user keys soon
Why do you launch new EC2 instances from EBS snapshots?
Help with AWS ec2 server
The Amazon EC2 Spot Team is here – Ask the AWS Experts!
Sidechannel md_clear cpu flags not being passed to EC2 instances?
Windows + Teradici PCoIP + Adobe Create Cloud on EC2 + Elastic GPU
What is the difference between a task, service, and EC2 Role?
Cloudviz.io - Auto generate AWS architecture diagrams
The AWS Cloud Development Kit (AWS CDK) is Now Generally Available
Automatically diagram your AWS architecture
Is CDK a "crutch"?
Just got a CloudWatch bill alert. Caused by EC2-ELB. But I don't think I have any ELBs or EC2 instances running. Any ideas?
EC2 Instances (G4) with NVIDIA T4 Tensor Core GPUs
We are AWS Auto Scaling Experts - Ask us Anything – Apr 29th @ 11AM PT / 2PM ET / 7PM GMT!
Anyone else getting SYN floods from AWS IPs?
In The Works – New AMD-Powered, Compute-Optimized EC2 Instances (C5a/C5ad)
We're rolling out the new EC2 Console Launch Templates experience! Give it a try and let us know what you think 😁 It will be live for all customers in the next few days. If you don't see it yet stay tuned. #AWS #EC2 #Console #LaunchTemplates
Is there a way to dump the entire environment into a csv? (vpc, sgs, ec2 instances, subnets, the whole thing)
What to look out for when moving from EC2 to RDS for Postgres?
Bottlerocket -- What is this thing?
Does EC2 + ElasticBeanstalk essentially make docker containers obsolete for web apps?
EC2 Spot instance
ELI5: AWS EC2 Savings Plans
How to limit data usage inside of a EC2 instance ?
Coordinating resource creation and modification in a small team
Only allow traffic to EC2 instance through CloudFront?
Transferring my file from my local machine to an ec2 instance
Help with event-driven architecture
Example of complex AWS CDK infrastructure
Snapshot correlation
Best practices when going from single instance to autoscaling server?
ec2 backup?
Elemental Media Convert: I don't know where to begin.
Question about Networking Order of Operations
Issue with storage gateways?
How are you securely tunneling to RDS instances in a private subnet?
Best practice for caching with Cloudfront and EC2
How can I use AWS CDK with multiple access keys in ~/.aws/credentials?
Question about reporting abuse to AWS
Connecting windows EC2 Instance to AD Domain Controller
I'm an AWS newbie. If I totally hose an EC2 instance, can I just restore a snapshot and be like nothing happened?
Which EC2 instance type has the best single core performance?
Quail - User friendly temporary EC2 instance provisioning
Hiding your 'origin' server for Cloudfront from the rest of the internet
Can't access the web server of a new instance I created.
Amazon EC2 Auto Scaling Introduces Predictive Scaling as a Native Scaling Policy
Export AWS Infrastructure Designs to CFN Templates
How to avoid turning our developers to Ops?
Want to host a private game server using EC2. How do I minimize cost?
Automatically set the outputs from CDK in your React app
Beginner question - are there public designs that companies publish to show their architecture at AWS?
VTx support? Bare metal seems the only option, but it's insanely expensive.
EC2 IIS hosted web app says Insecure?
Rescue mode "grub rescue" "emergency mode"
Can’t remember the name of media POC cloud formation thing…
Terminated EC2 instance still being billed.
How do I stop being charged from AWS?
Amazon Client VPN vs OpenVPN Installed on ec2 instance
Avoiding EC2 extra costs
Default vs custom EventBridge bus
EC2 instance suddenly at 100% CPU due to "system interrupts"
Dealing with heavy numbers of simultaneous connections
Amazon EC2 adds new AMI property to view timestamp of the latest instance launch using the AMI
EC2 image builder question
Can you force a tag on any new EC2 instance when upon creation?
Creating AWS Architecture diagram?
Add additional local pem key to ec2 instnace
How do cross-account deployments work in CDK
Spot Instance interruptions can now be tested directly from Amazon EC2 console via AWS Fault Injection Simulator integration
AWS Support will no longer fall over with US-EAST-1...
Stupid Question: Can DDoS attack or some other attack mess up EC2 Auto Scaling ?
Curious question: What packages and configurations are usually in your backend EC2 Instances for Java Applications?
Does my ec2 need an elastic IP?
Personal project suggestions to keep AWS architecting skills sharp?
Any guidance, advice or tips you have following an upgrade of EBS volume in production?
Why can I never get AWS tutorials to work? Am I just stupid? (rant)
Design Question for DR and keeping same IP schemes
Max Ganz's Redshift Combobulator
EC2 naming explained
Solution Architect Responsibilities
How to handle insufficient capacity when launching ec2 instances?
AWS/System architecture for my side project
Allow temporary access to EC2 that it's part of a Private Subnet
What's the best way to implement this solution?
AWS Let's Build a Startup Twitch Show
RHEL 8 EC2 disconnects and broken serial console
How do you handle domains, certificates and DNS with CDK?
Learning AWS and cloud as grad software engineer
How do you programmatically manage API creation and authentication from Nextjs client side to AWS API Gateway?
AWS CDK Language
Typing of Rust and Go SDKs - why is everything optional or a pointer?
Confused about "Up to 5 Gigabit" for network performance
How to find the IPv4:InUseAddresses?
Exceeding network bandwidth on an ec2 instance; how is that possible
Trying to work out an idea to setup multi region app hosting - the good, the bad and the ugly.
How have you used CDK unit tests in real life?
Free Review Copies of "Solutions Architect's Handbook"
R8g Instances Now Generally Available
I've been at this CloudWatch "Log Groups" thing for a long while, still can't...
My IP address changes daily from my ISP. I have a rule to allow SSH access only from my IP. How do I handle this in CDK?
How does AWS handle DMCA notices? We got an abusive/irrelevant DMCA notice
Upgrading from EC2 to ECR (httpd + php-fpm + WordPress)
Graviton processors and cost savings
Create an AMI from a desktop ubuntu system?
Migrating from Serverless Framework to AWS CDK
Is EC2, useful as a regular work machine !?
Serverless architecture for a silly project showcasing rejected vanity plates; did I do this the AWS way?
How can access an ec2 instance in a private subnet?
Is EC2 AMI+autoscaling good enough, or should I try something else?
Creating around 15 g5.xlarge EC2 Instances on a fairly new AWS account.
When setting up the web server EC2 instance, the web server EC2 instance works for several hours, and then it fails instance status checks and website goes down. Why is that?
Question about instances and RDP
What's the future of Amazon Linux?
I regret waiting so long to get a proper dex box at home instead of using an ec2
No P5 instances available in any region?
What AWS architecture challenge became much harder in production than expected?
Amazon EC2 beta (20 years ago today)
Amazon EC2 introduces application status checks
Why are spot g2.8xlarge instances $26/hr when you can buy them fixed duration for $1.4 to $1.8/hr?
Enterprise Network Architectures on AWS
SSM, Firefox and Windows
High latency in Multiplayer Game using EC2
AWS Beginner looking to host a headless server
"Throughput Optimized (ST1)" EBS limited to the EC2 network limits?
Need more speed than c4.8xlarge - thoughts?
Spot "fleet" of 1 t1.micro is 52% cost of t2.nano
Is it a security risk to grand sudo access to EC2 instance that doesn't store any AWS keys?
Hard numbers for Networking Performance?
US-EAST-1 experiencing increased error rates. (again!)

At a rough guess the compiler has specific tuning for the Apple M4, but the Pi and Graviton are just using more basic Neon or some other fallback.

This was all Linux and gcc with -O3 and -march=native options.

M4 and Graviton2 are both custom chips.

But if Apple threw some money or people at GCC to favor their silicon, maybe Amazon should do the same.

What size t4g were you running? Smaller sizes have a limit for how much CPU you can burn on them. A better apples to apples comparison would be to use a c class instance

I went back and ran on a m9g(Graviton 5) and added it to the plot

Nice benchmark — two things in the numbers are worth pulling apart.

First, the Xeon curve falling off past ~6000 samples is the giveaway that the large-N end isn’t measuring vector throughput anymore, it’s measuring memory bandwidth. Once the working set stops fitting in cache, a 512-bit register doesn’t help because the cores are waiting on DRAM. If you rerun with the data pinned in cache (or report GB/s alongside the speedup), the AVX-512 lead at large N should mostly flatten out to the bandwidth ratio.

Second, on the Graviton side, the t4g result is hurt by two things: it’s a burstable instance, so sustained runs can get throttled once credits run out, and std::experimental::native_simd on Arm only emits fixed 128-bit NEON — it can’t use the SVE2 vector length that Neoverse V3 (Graviton5) actually has. So the Graviton5 jump you’re seeing is mostly better cores and memory, not the wider vector path. A c7g or c8g vs the c8i would be the apples-to-apples comparison, and compiling with SVE2 enabled would be the interesting follow-up — that’s where the Arm numbers usually close the gap a lot more than the NEON baseline suggests.

Thanks for the input, truly.

I’m aware of the caching issue, but I keep those in the datasets so as to illustrate exactly that.

To your point of using the SVE2 instructions, I’m exploring that with some initially frustrating results. I’ve been manipulating the compiler settings with “-march=armv9.2-a+sve2 -msve-vector-bits=XXX”

Setting sve-vector-bits to 128, everything works as expected.

However, setting it to 512 the

std::experimental::native_simd::size()

reports the correct size of 8, I’m getting segfaults and comparison failures with the C++ code, even with simplest of loops. I’m going to go back and implement the C intrinsics with SVE2 and see if that works and raises the bar

It’s a shame posts like this appear with a downvote.

I’m sick of all the “my account is down!” posts - then someone posts something actually of interest, and cops a downvote.

.. so have an upvote - thx for posting.

I’ve been taking a look at the SVE/SVE2 intrinsics and their implementations. Yes, the spec goes up to 2048 bits, but unfortunately no is selling a chip like that at the moment. Graviton 2 has 128-bit registers, and Graviton 3 has 256-bit registers, but Graviton 5 goes back down to 128. :frowning:

Though there does seem to be some strangneses. Compiling with -march=armv8.5-a+sve for a Graviton 3(c7g)

implementation -msve-vector-bits=128 -msve-vector-bits=256
simd::size() 2 4
std::reduce 8x 4x
NEON intrinsics 14x 7x
vector_reduce_simd 10x 10x

Yes, when we boost the size of the vector, the performance of the NEON intrinsics goes down

agreed, the auto-vectorization defaults for newer silicon are usually way more aggressive out of the box