Showing posts with label cpu. Show all posts
Showing posts with label cpu. Show all posts

This Week I Learned - 2016 Week 23

Last week write-up or you might want to read the whole series.

Calculate the power supply needed for your Power Supply Unit (PSU). It seems that my HP Proliant ML110 G6's PSU of 300 watt seems sufficient enough. Maybe the issue is with the power socket or adapter? Next step, install different operating system to test it out. Or maybe I should proceed on building a HTPC instead? But find the required parts is quite an frustrating process. I've never realize that quite a lot of product, for example, casing is not available in MY.

AMD Athlon 5350 Kabini Quad-Core 2.05 GHz is my favourite CPU processor (or APU to be exact) right now besides the XEON X-series. This is a very unique processor that sits between 5150 and 5370 but that supports virtualization extension (AMD-V). Hence, this processor is suitable for building your own homelab which fully utilizes the quad-cores for virtualization. Furthermore, the power consumption is 25 Watt TDP. However, the motherboard choices for AM1l is quite limited but so far only Asus AM1l-A seems to support ECC Ram or not?

One good example of using this processor is building a pfSense firewall. Why one want to build and setup a homelab? Well, if you want to be a full stack engineer or just having some fun building a machine.

As it's very hard to find a single 5350 in MY. The next best option to go for A4 5000, which have similar features to Athlon 5350 but lower clock speed. The only available APU option right now here is BioStar A68N 5000. While having higher TDP, it's still a preferable choice when compare to Celeron J1800 or J1900 for its AES encryption support and less painful VMWare's ESXi installation.

How to teach yourself programming. Learning a new programming language is never hard, you just have to use it on daily basis and experienced the whole eco-system.

Something more about Perl. The official Perl's Docker image is up (via Reddit). So right now, we can have an isolated Perl environment for customization and development. So many things I want to try out, for examples, Moo (Minimalist Object Orientation), DNSMadeEasy Webservices API, and try to figure out how to define and use constant properly in Perl.

While we're on Docker, it seems the default Docker installation in my Ubuntu 16.04 cannot be executed by non-root user. To enable this,
$ sudo groupadd docker
$ sudo gpasswd -a ${USER} docker
$ sudo systemctl restart docker
$ sudo systemctl status docker
$ newgrp docker # no need to logout and login again
$ docker version

Chromiun OS for Single Board Computers (SOCs). Is time to use back the shelved Raspberry Pi 2.



Swift in Fedora 24 (Rawhide)

Swift, the language developed by Apple, which is set to replace Objective-C, was recently open sourced. However, the existing binary only available for Ubuntu and Mac OS. Hence, for Fedora user like myself, the only option is to install it through source code compilation.

First, install all the necessary packages.
$ sudo dnf install git cmake ninja-build clang uuid-devel libuuid-devel libicu-devel libbsd-devel libbsd-devel libedit-devel libxml2-devel libsqlite3-devel swig python-devel ncurses-devel pkgconfig

Next, create our working folder.
$ mkdir swift-lang

Clone the minimum repositories to build Swift.
$ git clone https://github.com/apple/swift.git swift
$ git clone https://github.com/apple/swift-clang.git clang
$ git clone https://github.com/apple/swift-cmark.git cmark
$ git clone https://github.com/apple/swift-llvm.git llvm

If you have slow internet connection and experiencing disconnection during clone, is best to clone partially. Otherwise, you've to restart from the beginning again.
$ git clone --depth 1 https://github.com/apple/swift-llvm.git llvm
$ cd llvm
$ git fetch --unshallow

If you have the great Internet connection, you can proceed with the remaining repositories.
$ git clone https://github.com/apple/swift-lldb.git lldb
$ git clone https://github.com/apple/swift-llbuild.git llbuild
$ git clone https://github.com/apple/swift-package-manager.git swiftpm
$ git clone https://github.com/apple/swift-corelibs-xctest.git
$ git clone https://github.com/apple/swift-corelibs-foundation.git

As Swift was configured to work in Ubuntu or Debian, you may encounter error several issues during compilation. These are my workaround.

/usr/bin/which: no ninja in ...
In Fedora, Ninja Built binary name is 'ninja-build' but Swift builder script expect it to be 'ninja'. We create an alias to bypass that.
$ sudo ln -s /usr/bin/ninja-build /usr/bin/ninja

Missing ioctl.h
During compilation, the ioctl.h header file was not found as the build script assumed it's located in '/usr/include/x86_64-linux-gnu' as shown below.
header "/usr/include/x86_64-linux-gnu/sys/ioctl.h"

Temporary workaround is to symlink the folder that contains these files.
$ sudo mkdir -p /usr/include/x86_64-linux-gnu/
$ sudo ln -s /usr/include/sys/ /usr/include/x86_64-linux-gnu/sys

pod2man conversion failure
The 'pod2man' doesn't seems to convert the POD file to MAN page as illustrated in error message below.
FAILED: cd /home/hojimi/Projects/swift-lang/build/Ninja-ReleaseAssert/swift-linux-x86_64/docs/tools && /usr/bin/pod2man --section 1 --center Swift\ Documentation --release --name swift --stderr /home/hojimi/Projects/swift-lang/swift/docs/tools/swift.pod > /home/hojimi/Projects/swift-lang/build/Ninja-ReleaseAssert/swift-linux-x86_64/docs/tools/swift.1
Can't open swift: No such file or directory at /usr/bin/pod2man line 68.

Upon this error message, the 'swift.pod' file has been corrupted and emptied. You'll need to restore it back from the repository.
$ git checkout -- docs/tools/swift.pod

We need to disable the '--name swift' parameter. This is done by commenting out the 'MAN_FILE' variable.
$ sed -i 's/MAN_FILE/#MAN_FILE/g' swift/docs/tools/CMakeLists.txt

Once all the workarounds have been applied, we'll proceed with our compilation. You do not really need to set the '-j 4' parameter for parallel compilation which can really reduce compilation time. By default, Ninja Build will compile code using the available CPU cores. Also, we just want the release (-R) build without any debugging information attached.
$ ./swift/utils/build-script -R -j 4

Add our compiled binary path to the system path.
$ cd /build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/
export PATH=$PATH:`pwd`

Lastly, check our compiled binary.
$ swift --version
Swift version 2.2-dev (LLVM 7bae82deaa, Clang 587b76f2f6, Swift 1171ed7081)
Target: x86_64-unknown-linux-gnu

Be warned, compilation took quite a while, maybe for several hours. This depends on your machine specification and the type of build. I've noticed my lappy was burning hot as four CPU cores were running at 100% most of the time. It's recommended during compilation, place your lappy near a fan or any place with good ventilation. See that the temperature exceed high threshold of 86.0°C.
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:        +95.0°C  (crit = +98.0°C)

thinkpad-isa-0000
Adapter: ISA adapter
fan1:        4510 RPM

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +97.0°C  (high = +86.0°C, crit = +100.0°C)
Core 0:         +94.0°C  (high = +86.0°C, crit = +100.0°C)
Core 1:         +97.0°C  (high = +86.0°C, crit = +100.0°C)

Under normal usage, the average temperature is roughly 50°C.
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:        +46.0°C  (crit = +98.0°C)

thinkpad-isa-0000
Adapter: ISA adapter
fan1:        3525 RPM

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +49.0°C  (high = +86.0°C, crit = +100.0°C)
Core 0:         +49.0°C  (high = +86.0°C, crit = +100.0°C)
Core 1:         +45.0°C  (high = +86.0°C, crit = +100.0°C)