Showing posts with label Other Work. Show all posts
Showing posts with label Other Work. Show all posts

Tuesday, 4 March 2014

Set Up Visual Studio 2012 for CUDA Dynamic Parallelism

In this post i am going to show you how to set up Visual Studio 2012 to compile CUDA code which uses dynamic parallelism.

What is Dynamic Parallelism?


Dynamic parallelism enables the GPU to create new work for itself without ever having to involve the CPU by allowing CUDA kernels to call other CUDA kernels.

Nvidia 2013
This is a powerful tool for CUDA developers as there is now no longer the need to pass data between the host and device as launch configuration decisions can now be made at runtime by threads executing on the device.

In order to make use of dynamic parallelism you must have an Nvidia GPU with compute capability 3.5

Dynamic Parallelism Example


As with every first code example we will look at a simple 'hello world' program which uses dynamic parallelism. 


Here we have two kernels, the parent kernel and the child kernel. Out parent kernel calls the child, waits for it to complete its work and then carries out some work of its own. 

When we initially try and build this code using visual studio we will get the following error. 


Visual studio is complaining that we can only call kernels within kernels if we have a card of compute 3.5 or higher. To let visual studio know that we do infact have a suitable card we need to change a few properties. 

To do this we open up the project properties by right clicking on the project. 



The first setting we need to change is to tell CUDA to generate relocatable device code by selecting 'Yes (-rdc=true)'


Next we have to tell CUDA to use compute 3.5 by changing the code generation to 'compute_35,sm_35'


We then need to tell the runtime library to use the multi threaded library. If we are in debug mode we select 'Multi-Threaded Debug (/MTd)' or if we are in release mode 'Multi-Threaded (/MT)'


Finally inside the linker properties we add an additional dependency to 'cudadevrt.lib' 

After following these steps our project will now build successfully and we should get the following output. 


This has been to mostly help remind myself how to set up visual studio in the future if i forget but hopefully it can help out a few other people as well. 

Any questions or if you are struggling with anything feel free to send me an email at craigmcmillan01@outlook.com with blog in the subject and i will be happy to help. 

Thursday, 2 January 2014

Parallel IDEA Algorithm

For one of my coursework's this year we had to parallelize the International Data Encryption Algorithm using different CPU concurrency techniques and analyse the effect on performance.

This post will provide an overview of the work carried out and the results that were obtained. If you are interested in reading the full report, you can do so at the following link

Sunday, 10 February 2013

Programming Project: Bounding Spheres

A very very rubbish version of space invaders showing off the messaging system and simple collision detection using bounding spheres.



Email: 10004794@napier.ac.uk - Please put blog in the subject.
Xbox Gamertag: craigmcmillan01
Twitter: 
steam: craigmcmillan01
add or follow and we can game!

Wednesday, 9 January 2013

Code Challenge: "Guess That Number!"

I discovered the sub Reddit dailyprogrammer which post up different programming challenges for people to solve, so for a bit of fun when i have the time i am going to pick some of the challenges and give them a go and then i will stick my code up here for any one that is interested and to hopefully get some feedback as well.

The first challenge i have chosen is Challenge #115 [Easy] Guess-That-Number game which i have attempted to do in C++.

The aim of the challenge was to write a program which guessed a number between 1 and 100 and then ask the user to guess what that number was and then either tell them if their guess is too high, too low or correct. or exit if the user enters "Exit". Here is my code.


I am not entirely sure if this is the best way to do it but what i have done is this. I read in the users guess, try and convert the input into an integer, if it is successful i check if the number is equal to, higher than, lower than or out of range and then return a string value based upon what it is and then display this string value to the user. If the conversion fails i check to see if the user has entered the string "Exit" and if they have i break; and end the program. Any other input i display an error message. This continues on until the user guesses the correct value at which point the loop is exited and the program terminates. 

You can find and download the code from my git hub account here, feel free to use the code as you wish and if you make any improvements please let me know, i would love to hear from you. 

Friday, 7 December 2012

Arms Dealer Game

As part of my software development 3 module we were tasked with writing the Java code for a space game using design patterns, threads and a GUI. We also had the option to design our own game however and i choose to do this instead.

Game Design 


The player plays as an arms dealer who has to buy and sell weapons and ammunition to other dealers in the game. The player will specify the number of turns they wish to play for and must try and get as much money as they can before they run out of turns.

Each turn the player will be asked by another dealer if they would like to deal with them and they can either refuse or accept this offer. If they refuse they will continue to be asked by other dealers until they accept an offer. If the accept they will be taken to the deal screen.

In the deal screen they will have the option to buy and sell items and to commit or undo the deal. When a player buys or sells an item that item will be added to a separate list box and there money will be amended. When the player presses commit the player and dealer’s inventories will be updated accordingly. When they press undo they will go back to the start of the deal. 

Dealers(including player) can have arms embargoes placed upon them which will effect players who choose to deal with them as there is a risk they could be fined  and lose money.
Dealers can also change their behaviour from willing to deal or does not want to deal and this will decide if they are an option for the player to deal with. 

The actual game

Start Screen 


The start screen is the first GUI that the player is presented with, it has 4 buttons which the player can select from. They can either load a previous game, start a new game, close the game or display the instruction screen.

Instruction Screen


If the player presses the instruction button they are presented with the instructions for the game. They can then close this screen and choose another operation.

 Player Home Screen


If the player selects new game or load game they will be taken to the player home screen where they can view their current stats such as the items they have in their inventory and how much money they have. From this screen they can either choose to undo a turn or go to the next turn.

New Deal Screen


When the player selects next turn they will be presented with a proposal from a dealer who is willing to deal with them. They can either except or refuse this proposal. If they refuse a new dealer will make an offer. This will continue until an offer is accepted.  

Buy and Sell Screen


When the player accepts a dealers offer they will be taken to the buy and sell screen where they will be presented with the dealer’s inventory and their own inventory. They are then able to select items from their inventory which they would like to sell and press the sell option, this will move the item from their inventory to the sell list box. If they try and sell an item which the dealer can’t afford they will be presented with the option to continue and lose money or cancel the transaction.


The player is also able to select items from the dealer’s inventory they wish to buy and press the buy option, this will remove the item from the dealer inventory and place it in the buy list box. If the player does not have required funds they will be shown an error message and will not be able to buy the item.


If the player selects undo the sell and buy list boxes will be wiped and the player’s money will be set back to what it was at the start of the turn and the items added back to their inventories. When the player presses commit the deal is committed and the sold items removed permanently from the inventory and their bought items added. If the game still has remaining turns they will be taken back to the player home screen and will continue to play through again until no turns remain.

Leader board


Once there are no more turns remaining in the game the player is shown the leader board for the game which shows how much money each dealer made and how well they done in comparison. The player’s only option at this point is to close the window which will also end the game. It is at this point that the game is serialized and can be reloaded again from the start screen. 

Thanks for reading! Any questions or feedback i would love to hear from you. If any one would like to try and play the game feel free to email and i will send you a copy, be warned though the game is still being worked on and has a few bugs still to be fixed. 

Email: 10004794@napier.ac.uk - Please put blog in the subject.
Xbox Gamertag: craigmcmillan01
Twitter: 
steam: craigmcmillan01
add or follow and we can game!

Wednesday, 21 November 2012

C# - NFS Bank System

This week i have had a break from graphics programming as i have had coursework deadlines for my other modules.

The coursework for my software engineering module included designing, implementing and testing a system for a fictional bank.  The system had to allow a user to log in as either a clerk, chief clerk or customer and perform several different operations.

these operations included creating and removing new customers, creating new savings and mortgage accounts and the ability for the customer to credit or debit to these accounts and the ability to run a number of reports.

Log in screen

Chief Clerk screen

Clerk screen

Customer screen
Thanks for reading! Any questions or feedback i would love to hear from you. 
Email: 10004794@napier.ac.uk - Please put blog in the subject.
Xbox Gamertag: craigmcmillan01
Twitter: 
steam: craigmcmillan01
add or follow and we can game!

Friday, 12 October 2012

Lets Play: PAYDAY: The Heist

This week i picked up the new issue of PC gamer and along with the awesome articles was a code for a free copy of PAYDAY: The Heist!


Payday was developed by OverKill Software and published by Sony Online Entertainment and plays as a 4-player co-operative first person shooter. You play as one of four robbers who must work together to go complete a series of heists. There are 9 heists in total(you need the wolf pack dlc for 2 of them) ranging from robbing a bank to breaking into mercy hospital.

So far i have only played a few hours of payday on-line with mark and scott but it is pretty awesome. There are lots of intense moments in the game and you really need to work as a team to achieve your objectives otherwise things can fall apart pretty quickly and before you know it your handcuffed and on the floor while your team-mates are a man down.

Overall payday is a very good game, there are a few parts which could have been a little bit better such as the sawing sequences take forever and get a little bit repetitive however the adaptive enemy tactics meaning no scenario will ever play out the same way twice help to keep things interesting and challenging. There are also a few bits where the AI are a little silly or when you shoot people and they go flying up in the air or a mile down the street but this isn't a big deal and personally i think it adds to the character of the game.

I definetly recommend picking up a copy of payday if you can. if you are ever around a big supermarket go in and get yourself a copy of PC gamer, it is a fantastic magazine and this months issue has a steam code for PAYDAY: The Hesit and the dota 2 beta. If not it is available on steam and PlayStation 3 on the PSN store for around £15.

Here is a video of me, mark and scott playing payday.

if you head over to marks blog he has the video from his perspective, go check it out!

Thanks for reading! Any feedback is greatly appreciated and i would love to hear from you.
Email: 10004794@napier.ac.uk - Please put blog in the subject.
Xbox Gamertag: craigmcmillan01
Twitter: 
steam: craigmcmillan01
add or follow and we can game!

Tuesday, 22 November 2011

Some Lovely Pictures...

So my dad got a new camera a while back and has been getting into photography and since im a little bored here are some of the pics he has taken. 














thanks for reading!
Gamertag: craigmcmillan01
Twitter: craigmcmillan01
steam: craigmcmillan01
add or follow and we can game!

Thursday, 29 September 2011

Battlefield 3 Beta


Now I have been excited about this game for a long time and my main goal when i finish uni is to do everything I can to work for Dice even if it involves doing things I wont be particularly proud of...

When I woke up this morning the first thing I done even before I left my bed was switch on my 360 and download the Battlefield 3 beta and for the next 30mins I sat and stared at the screen while the download progress slowly went up. Finally it reached 100% and I could begin!

The very first thing i noticed once i got into a game was the graphics and the level of detail that was in the face's and body's of my squad mates as we waited to go and destroy some M-COM stations. I clicked the stick in to crouch down and ended up in prone, I was surprised as i had totally forgot they were bringing it back into the game and couldn't wait to try it out with a sniper and maybe be able to kill people.

"pretending that i was free running" 
After the 30second countdown the game began, i immediately ran forward heading straight for the objective and went to jump over a wall. The animation that played as I jumped made the simple action really fun and I then spent the next 5 minutes running around and jumping over the walls pretending that i was free running. Eventually i was killed and brought back into what the game is all about, killing people and blowing shit up!

As i respawned on my squad mate i was met with a group of enemies firing at me, In my panic i threw a grenade into the middle of them and luckily managed to find some cover before a huge explosion went off sending parts of a wall and statue flying every where and gaining me my first kill when suddenly from behind I am grabbed by an enemy and spun around as he swiftly plunged his knife into my neck! i was left in awe in the beauty of the animation and again in the detail of the graphics in my killers face and have never before in a game been left wanting to die again!

Over the next 20 mins or so me and my squad continued to battle through against the enemy working our way forward destroying their M-COM stations and working our way towards victory. Finally we got to the last objective and I was the one sitting in front of the M-COM station ready to plant the charge my squad having sacrificed themselves to get me this far, pressing B i sat watching the circle fill and what felt like forever it eventually reached the top and the alarm started sounding. This was it i had done it! with the help of my squad we had won the game! or so I thought... from the left of my screen i see someone sitting aiming an RPG right at my face and before i could fire BOOM! im dead and they have disarmed the charge and won the round, I couldnt believe it!

Overall my first experience with Battlefield 3 beta was awesome and I couldn't wait to get into the next round and get my revenge on the enemy team this time defending the M-COM stations.

over the next few games I played I came across a few problems, every so often the sound kept cutting out which started to become a little annoying at times and the same was happening with my mates aswell. Another problem was squads when me and my mates created a squad and then attempted to join a game it kept sticking us in different squads or even different teams. The biggest problem though is that at the time of writing this the servers are down and i cant play! I'm sure it is just for maintenance but I'm having withdrawal symptoms already!

I cant wait to play this on the PC when I finally get mine fixed and until the 28th of October when they full game is released, I have high expectations for it and I'm sure it will exceed them!

Gamertag: craigmcmillan01
Twitter: craigmcmillan01
steam: craigmcmillan01
add or follow and we can game!