NVIDIA GPU Tutorials for CUDA

We recently had some amazing GPU CUDA programming webinars at Lockheed Martin taught by NVIDIA that are now available on YouTube.  Enjoy them! They were chock full of really useful GPU programming information.
1.       Intro to GPU computing: http://youtu.be/hlN_JCx6QoQ
2.       Drop-in acceleration using libraries: http://youtu.be/TyRMpi1wuhk
3.       Accelerating Code with a CUDA Enabled Language: http://youtu.be/mdUhtsGzkvY
4.       Profiler led optimizations of CUDA code: http://youtu.be/MwaiYSt_UOg

Windows Batch Code: Determine if a String is in the Path Variable and Execute or Download the Missing Software From A Website

This code section below was very helpful when writing a quick Windows batch file to determine if a piece of software was available at a Windows Command Prompt or Powershell by checking the Path environment variable for a keyword.  In the case below, we check to see if NodeJS is installed, and if it is we execute.  Otherwise, we queue a download of NodeJS MSI installation to Windows Temp Directory and then kick off the installation!

 

Windows Batch Code

SET VWF_DIR=%VWF_DIR%

REM Check to see if Node is installed and accessible from the Path variable

set test=c:\program files (x86)\nodejs

call:inPath test

REM If it is, we start up the NodeJS Server. The NodeJS server accepts command line parameters.
REM C:\> vwf –help will display all of the currently available parameters accepted by Virtual World Framework

IF NOT ERRORLEVEL 1 pushd %VWF_DIR% && cmd.exe /C npm install && popd && cmd.exe /C node “%VWF_DIR%/node-server.js” %*
IF ERRORLEVEL 1 set test=c:\program files\nodejs && call:inPath test
IF ERRORLEVEL 1 bitsadmin.exe /transfer “NodeJS is not installed. We are downloading NodeJS for you.” http://nodejs.org/dist/v0.10.22/x64/node-v0.10.22-x64.msi C:\windows\temp\node-v0.10.22-x64.msi & call C:\windows\temp\node-v0.10.22-x64.msi & echo Node is now installed. You will need to restart your computer and execute VWF again to start your server.
endlocal

:inPath pathVar
::
:: Tests if the path stored within variable pathVar exists within PATH.
::
:: The result is returned as the ERRORLEVEL:
:: 0 if the pathVar path is found in PATH.
:: 1 if the pathVar path is not found in PATH.
:: 2 if pathVar is missing or undefined or if PATH is undefined.
::
:: If the pathVar path is fully qualified, then it is logically compared
:: to each fully qualified path within PATH. The path strings don’t have
:: to match exactly, they just need to be logically equivalent.
::
:: If the pathVar path is relative, then it is strictly compared to each
:: relative path within PATH. Case differences and double quotes are
:: ignored, but otherwise the path strings must match exactly.
::
::————————————————————————
::
:: Error checking
if “%~1″==”” exit /b 2
if not defined %~1 exit /b 2
if not defined path exit /b 2
::
:: Prepare to safely parse PATH into individual paths
setlocal DisableDelayedExpansion
set “var=%path:”=””%”
set “var=%var:^=^^%”
set “var=%var:&=^&%”
set “var=%var:|=^|%”
set “var=%var:<=^<%”
set “var=%var:>=^>%”
set “var=%var:;=^;^;%”
set var=%var:””=”%
set “var=%var:”=””Q%”
set “var=%var:;;=”S”S%”
set “var=%var:^;^;=;%”
set “var=%var:””=”%”
setlocal EnableDelayedExpansion
set “var=!var:”Q=!”
set “var=!var:”S”S=”;”!”
::
:: Remove quotes from pathVar and abort if it becomes empty
set “new=!%~1:”=!”
if not defined new exit /b 2
::
:: Determine if pathVar is fully qualified
echo(“!new!”|findstr /i /r /c:^”^^\”[a-zA-Z]:[\\/][^\\/]” ^
/c:^”^^\”[\\][\\]” >nul ^
&& set “abs=1” || set “abs=0”
::
:: For each path in PATH, check if path is fully qualified and then do
:: proper comparison with pathVar.
:: Exit with ERRORLEVEL 0 if a match is found.
:: Delayed expansion must be disabled when expanding FOR variables
:: just in case the value contains !
for %%A in (“!new!\”) do for %%B in (“!var!”) do (
if “!!”==”” endlocal
for %%C in (“%%~B\”) do (
echo(%%B|findstr /i /r /c:^”^^\”[a-zA-Z]:[\\/][^\\/]” ^
/c:^”^^\”[\\][\\]” >nul ^
&& (if %abs%==1 if /i “%%~sA”==”%%~sC” exit /b 0) ^
|| (if %abs%==0 if /i “%%~A”==”%%~C” exit /b 0)
)
)
:: No match was found so exit with ERRORLEVEL 1
exit /b 1

Using GitHub Branch Names With Forward Slashes and Jenkins Together

One of my pet peeves with Jenkins existed around the use of forward slashes in our branch names on Virtual World Framework.  While the forward slash “/” was accepted by GitHub (ie. branch/branch-name) as an acceptable character, Jenkins would blow up when trying to pull from this branch name structure.

The solution for using forward-slashes branch names in Jenkins was incredible easy however. You simply need to add origin/ to the beginning of your branch name when filling in the “branches to build” Branch Specifier.

Thus:

origin/branch/branch-name 

allows Jenkins to poll and pull changes specific to a branch with a forward slash in its name.  Simple!

Virtual World Framework and HAProxy 1.5 How To Setup Configuration

When setting up our operational environment on Amazon Web Services, we had a number of interesting constraints.

  • We were cost constrained to maintain the minimum number of servers possible.
  • We needed to support Jenkins for Continuous Integration and Redmine for Issue Tracking.
  • The VWF demonstrations utilize websockets and secure websockets which required us to support websockets / secure websockets.
  • We needed to support multiple subdomains which point to multiple Ruby Thin web servers/ Node.js web servers on the back-end to host our executing branch configurations from GitHub.
  • We needed to allow an SSL pathway for internal Lockheed network engineers to access.
  • We required compression
  • We required all traffic over port 80
  • We needed to reroute a subdomain to point to an sh script for installation hosted on GitHub

To solve these issues, HAProxy came in to save the day allowing us to achieve all of these goals by serving as our front-end service proxy for our operational environment to handle incoming client requests.  HAProxy 1.5, although still in development, is stable enough and capable of handling reverse proxying of websockets for HTML5 AND handles compression on the fly as well.

Below is our configuration file.  Please leave questions in the comments if you have any!

HAProxy Configuration for Virtual World Framework

————————————————————————————————–

global

log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
#chroot /usr/share/haproxy
user haproxy
group haproxy
daemon
debug
#quiet

defaults

log global
mode http
option httplog
option http-server-close
option dontlognull
retries 3
option redispatch
option contstats
option forwardfor
stats enable
stats refresh 10s
stats uri /stats
compression algo gzip
compression type text/html text/plain text/css model/vnd.collada+xml application/javascript
timeout connect 360s
timeout client 360s
timeout server 180s
timeout http-keep-alive 60s
timeout http-request 60s
timeout queue 60s
timeout tarpit 60s
timeout tunnel 3600s

frontend public

bind *:80
acl is_jenkins hdr_beg(host) -i jenkins.
acl is_redmine hdr_beg(host) -i redmine.
acl is_www hdr_beg(host) -i www.
acl is_integration hdr_beg(host) -i integration.
acl is_development hdr_beg(host) -i development.
acl is_download hdr_beg(host) -i download.
acl is_test hdr_beg(host) -i test.
acl is_get hdr_beg(host) -t get.
use_backend jenkins if is_jenkins
use_backend redmine if is_redmine
use_backend development if is_development
use_backend integration if is_integration
use_backend download if is_download
use_backend www if is_www
use_backend test if is_test
use_backend get if is_get
default_backend www

backend www

timeout server 30s
server www1 127.0.0.1:5000
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend integration

timeout server 30s
server integration1 127.0.0.1:5001
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend development

timeout server 30s
server integration1 127.0.0.1:5002
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend test

timeout server 30s
server integration1 127.0.0.1:5003
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend jenkins

timeout server 30s
server jenkins1 127.0.0.1:6001
option http-server-close
cookie JSESSIONID prefix

backend redmine

timeout server 180s
server redmine1 127.0.0.1:6000
option http-server-close
cookie JSESSIONID prefix

backend download

timeout server 180s
server download1 127.0.0.1:8081
option http-server-close
cookie JSESSIONID prefix

backend get

redirect location https://raw.github.com/virtual-world-framework/vwf/branch/vwf-install-scripts/support/build/Scripts/install.sh