Analysis of Blender

Introduction
Blender is a very powerful, open source, 3D animation suite. It allows for modeling, rigging, animating, game development, and many more amazing features. Blender is cross platform, it runs on windows, mac, and linux. This is a attempt to analyze the blender package to see how much work is required to port it to aarch64, arm64bit

Unfortunately a lot of this analysis is somewhat inaccurate. This is due to the amount of SIMD vector programming that is within a lot of these files. Also the search was not tuned to find SSE, NEON, or any vector programming, though it probably should have been considering the program.

Get Package:

fedpkg clone -a blender
cd blender
fedpkg prep
cd blender-version

Create a list of files to search:

find ./ | egrep -i "\.s$|\.asm$|\.c$|\.cpp$|\.h$|\.cc$" >> ~/spo600-package1/files.txt

Search for source assembly:

egrep -i "\.s$|\.asm$" ~/spo600-package1/files.txt
(no source assembly files found)

Search for in-line assembly:

egrep -i "asm\(|__asm" $(cat ~/spo600-package1/files.txt) | awk 'BEGIN{FS=":"}{print $1}' | sort -u
./extern/bullet2/src/BulletCollision/BroadphaseCollision/btDbvt.h
./extern/bullet2/src/LinearMath/btConvexHullComputer.cpp
./extern/bullet2/src/LinearMath/btQuickprof.cpp
./extern/bullet2/src/LinearMath/btVector3.cpp
./extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
./extern/Eigen3/Eigen/src/Core/util/Macros.h
./extern/Eigen3/Eigen/src/Core/util/Memory.h
./extern/libmv/third_party/glog/src/stacktrace_powerpc-inl.h
./extern/libmv/third_party/glog/src/stacktrace_x86-inl.h
./extern/libmv/third_party/glog/src/utilities.h
./intern/cycles/util/util_system.cpp
./intern/moto/include/MT_assert.h
./source/blender/blenlib/intern/cpu.c

Raw Notes on Files
File:/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDbvt.h
Notes:
-Option to use intrinsics instead of assembly

// Use only intrinsics instead of inline asm
#define DBVT_USE_INTRINSIC_SSE  1

-Intrinsics may be “11% slower”
-Intrinsics vs assembly for this file can be found here.
Decision:
This file has an option to use SSE intrinsics or assembly. However both of these are platform specific to x86_64 architecture.

File:
./extern/bullet2/src/LinearMath/btConvexHullComputer.cpp
Notes:
-Asm is disabled in this file, shown here
-All assembly is within many ifdefs

#ifdef USE_X86_64_ASM

-Because of the commented out line none of these should run
Decision:
Does not need to be modified, all assembly #ifdef have been disabled due to a bug.

File:
./extern/bullet2/src/LinearMath/btQuickprof.cpp
Notes:
-Assembly was being used for time
-All assembly has been commented out in file
Decision:
Does not need to be modified, all assembly is commented out.

File:
./extern/bullet2/src/LinearMath/btVector3.cpp
Notes:
-File is full of intrinsics
-Lots of vector stuff
-Assembly is used for Apple here
-Assembly used for vector(SIMD) not quite sure what is going on here(closer look shows this is under arm NEON intrinsics)
-Some conditional use of SSE(Streaming SIMD Extensions)
Some conditional use of arm specific intrinsics
Decision:
Some optional assembly inside. There is a lot of platform specific intrinsics in this file. The fact that Arm NEON intrinsics are in there though, is good, since it may help in the porting to aarch64, since they may use something similar to NEON.

File:
./extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
Notes:
-All assembly is commented out
-“_mm” intrinsics are used everywhere, intel intrinsics?
Decision:
More platform specific intrinsics for the intel platform.

File:
./extern/Eigen3/Eigen/src/Core/util/Macros.h
Notes:
-EIGEN libraries for C/C++
-Linear algebra, matrix, and vector operations
-I think this is portable
Decision:
More intrinsics. Might be an issue.

File:
./extern/Eigen3/Eigen/src/Core/util/Memory.h

File:
./extern/bullet2/src/LinearMath/btConvexHullComputer.cpp

New Issue: Arch Specific Intrinsics
After finding so many file containing intrinsics that are platform specific I decided to stop and do another search. There are a lot of files found that may contain x86 intrinsics. I have not yet found out if all of these files are required, or if they are optionally called. However, considering that some package dependencies try to install only if the platform is x86, I am thinking that this program was made only for x86, however the fact that arm NEON intrinsics are found, make it that much more confusing.

Search for some intrinsics:

grep "_mm" $(cat ~/spo600-package1/files.txt ) | awk 'BEGIN{FS=":"}{print $1}' | sort -u
./extern/bullet2/src/BulletCollision/BroadphaseCollision/btDbvt.h
./extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
./extern/bullet2/src/BulletCollision/Gimpact/gim_memory.h
./extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
./extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
./extern/bullet2/src/LinearMath/btMatrix3x3.h
./extern/bullet2/src/LinearMath/btQuadWord.h
./extern/bullet2/src/LinearMath/btQuaternion.h
./extern/bullet2/src/LinearMath/btScalar.h
./extern/bullet2/src/LinearMath/btVector3.cpp
./extern/bullet2/src/LinearMath/btVector3.h
./extern/Eigen3/Eigen/src/Core/arch/SSE/Complex.h
./extern/Eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h
./extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
./extern/Eigen3/Eigen/src/Core/util/Memory.h
./extern/Eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h
./extern/Eigen3/Eigen/src/LU/arch/Inverse_SSE.h
./extern/libmv/libmv/simple_pipeline/detect.cc
./extern/libmv/libmv/tracking/brute_region_tracker.cc
./extern/libopenjpeg/dwt.c
./extern/libopenjpeg/mct.c
./extern/libopenjpeg/opj_malloc.h
./intern/audaspace/intern/AUD_JOSResampleReader.cpp
./intern/cycles/kernel/kernel_bvh_subsurface.h
./intern/cycles/kernel/kernel_bvh_traversal.h
./intern/cycles/util/util_math.h
./intern/cycles/util/util_types.h
./intern/guardedalloc/intern/mallocn.c
./intern/guardedalloc/intern/mmap_win.c
./source/blender/blenkernel/BKE_subsurf.h
./source/blender/blenkernel/intern/multires.c
./source/blender/blenkernel/intern/subsurf_ccg.c
./source/blender/blenlib/intern/math_geom.c
./source/blender/editors/object/object_bake.c
./source/blender/freestyle/intern/geometry/matrix_util.cpp
./source/blender/imbuf/intern/cineon/cineonlib.h
./source/blender/makesrna/intern/rna_tracking.c
./source/blender/makesrna/intern/rna_userdef.c
./source/blender/render/intern/raytrace/bvh.h
./source/blender/render/intern/raytrace/svbvh.h

Installing Blender on aarch64 Failed
So I decided to try installing Blender on aarch64 to see what happens, however the first thing I notice is some of it’s build dependencies have not been built for aarch64. I looked on arm koji and could not find a built package.

yum-builddep blender.spec
Error: No Package found for OpenImageIO-devel

I decided I would try and build it(if it was easy), but it failed and seems to have a script inside it that tries to find out the architecture and fails with an error when it decides it is not x86.

# Start with unknown platform
     18 platform ?= unknown
     19 
     20 # Use 'uname -m' to determine the hardware architecture.  This should
     21 # return "x86" or "x86_64"
     22 hw := ${shell uname -m}
     23 #$(info hardware = ${hw})
     24 ifneq (${hw},x86)
     25   ifneq (${hw},x86_64)
     26     ifneq (${hw},i386)
     27       ifneq (${hw},i686)
     28         $(error "ERROR: Unknown hardware architecture")
     29       endif
     30     endif
     31   endif
     32 endif

Added a couple lines to skip this platform check:

ifneq (${hw},aarch64)
endif

This allowed the package to start building, however it needed many build deps. Further investigation into this package shows that it has multiple build dependencies that are have also not been built for aarch64.

I will stop here with trying to get Blender installed on aarch64 as I am getting sidetracked and will move back to analyzing the actual assembly code in Blender.

yum-builddep OpenImageIO.spec
Error: No Package found for Field3D-devel
Error: No Package found for hdf5-devel

Conclusion:
For now I have stopped working on blender, it may be too early in the development of aarch64 to port it. However if I were to continue I would look through options for compiling blender with many platform specific features turned off. This would be useful in determining which files must be ported to aarch64, and which are optional.

Advertisements

About oatleywillisa

Computer Networking Student
This entry was posted in SBR600 and tagged , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s