Raspberry BASIC

Author Topic: Swift RPi  (Read 8965 times)

admin

  • Administrator
  • *****
  • Posts: 5
    • View Profile
Swift RPi
« on: November 24, 2019, 04:23:56 AM »
@hippy,

Download the latest 5.1.2 build below and follow the install instructions.

Great if you would join us here.
« Last Edit: November 30, 2019, 11:41:01 PM by admin »

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: Swift RPi
« Reply #1 on: November 30, 2019, 07:16:58 AM »
I submitted an issue on  the Swift for ARM repository and the maintainer said he wasn't seeing the IF compare issue with  the current build (5.12) of the Swift compiler. The posted binaries are 5.11 so I decided to build Swift from source. This repository is a front end  build for the RPi but grabs the source from Apple's release source repositories. I had to move the llvm-project directory of files/directories down to base directory so the build.sh script would run. Since I'm building on the RPi 4B with 4 GB of memory, I passed on the swap file set of instructions.  I'll post the release .tar.gz when it finishes the build, (says a couple hours)

« Last Edit: November 30, 2019, 07:21:20 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: Swift RPi
« Reply #2 on: November 30, 2019, 05:54:07 PM »
The Swift 5.12 build was successful and it built the distribution tar.gz. I screwed up with 5.11 and installed it in /usr/bin instead of /home/pi/user/bin. One should add this directory to their path.

I'll post a link or attach 5.12 once I do some basic testing.
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: Swift RPi
« Reply #3 on: November 30, 2019, 10:34:14 PM »
I built and uploaded Swift 5.1.2 released on November 7, 2019 and put it on the server. I plan to create a Swift child board under Other Languages that I will added to the forum. The goal to find a mentor for each of the languages.

swift-5.1.2_armv7.tgz Download

Extract to your user directory and add PATH="$HOME/usr/bin:$PATH" to the system path.

Install dependencies.  sudo apt install clang libicu-dev libcurl4-nss-dev curl


I attached a tar -t listing of the release if you want to see what is included.

I'm looking forward to hear your experience with Swift on the RPi.


« Last Edit: December 01, 2019, 03:05:45 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: Swift RPi
« Reply #4 on: December 02, 2019, 01:46:49 AM »
I installed Swift for Windows and ran the 1mil3.swift (compiled) on my new laptop running Windows 10 Pro.


PS C:\Swift\examples> Measure-Command {.\main.exe | Out-Default}
r LEN:  999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal:  100000


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 1
Milliseconds      : 305
Ticks             : 13053398
TotalDays         : 1.5108099537037E-05
TotalHours        : 0.000362594388888889
TotalMinutes      : 0.0217556633333333
TotalSeconds      : 1.3053398
TotalMilliseconds : 1305.3398



PS C:\Swift\examples>


No idea why this is so slow on the RPi 4B.
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: Swift RPi
« Reply #5 on: December 02, 2019, 02:18:22 AM »
Swift Online Playground

It runs almost instantly online as well.
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: Swift RPi
« Reply #6 on: December 02, 2019, 04:11:35 AM »
I installed Swift 5.1.2 on my Ubuntu 19.10 LIVE (persistent) that runs off my laptop and here are the results of 1mil3.swift compiled.


ubuntu@ubuntu:~/swift-dev/examples$ /usr/bin/time ./main
r LEN:  999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal:  100000
0.45user 0.01system 0:00.47elapsed 99%CPU (0avgtext+0avgdata 20132maxresident)k
0inputs+8outputs (0major+5273minor)pagefaults 0swaps
ubuntu@ubuntu:~/swift-dev/examples$

« Last Edit: December 02, 2019, 04:14:40 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: Swift RPi
« Reply #7 on: December 02, 2019, 03:50:31 PM »
I'm going to pass my findings over to the RPi Swift maintainer and hope he can find out why Swift runs so slow on the RPi.
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 234
    • View Profile
    • ScriptBasic
Re: Swift RPi
« Reply #8 on: December 11, 2019, 01:56:07 AM »
I tried the latest submission for Swift on my laptop Ubuntu 19.10 64 bit. It looks to me that  the problem is specific to ARM. I typically see a 4-5 X speed difference between my Lenovo laptop and the RPi 4B 4GB.


ubuntu@ubuntu:~/swift-dev/examples$ /usr/bin/time ./main
t LEN:  999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal:  100000
0.19user 0.01system 0:00.23elapsed 91%CPU (0avgtext+0avgdata 16868maxresident)k
10264inputs+24outputs (31major+2804minor)pagefaults 0swaps
ubuntu@ubuntu:~/swift-dev/examples$ time ./main
t LEN:  999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal:  100000

real   0m0.227s
user   0m0.210s
sys   0m0.016s
ubuntu@ubuntu:~/swift-dev/examples$

« Last Edit: December 11, 2019, 02:05:55 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

AIR

  • BASIC Developer
  • *
  • Posts: 16
  • Code Jockey
    • View Profile
Re: Swift RPi
« Reply #9 on: December 11, 2019, 06:31:06 AM »
That's in line with what I'm seeing on my Mac, using the official Apple Swift.

AIR.