Category Archives: Uncategorized

Porting code from Nvidia GPU to AMD : lesson learned

In the past several weeks I have been porting a codebase from Nvidia CUDA platform to AMD HIP. Several critical issues were encountered, some solved, some attributed to compiler bugs, some remaining unfathomable to me.

There are 3 important things I have learned so far from the painstaking debugging process.

  • An unsigned integer with n bits only allows 0~(n-1) times bitwise left shift (<<). Excess shifts lead to undefined behavior. For Nvidia platform, 0 bit will be added, whereas for AMD, 1 bit will be added!!!
  • Currently there is a serious compiler bug: the wavefront vote function __any(pred) , which is supposed to work like __any_sync(__activemask(), pred) in CUDA, yields incorrect result in divergent threads!!!
  • This is very easy to miss: the parameter of wavefront vote functions __any(pred), __all(pred), etc is a 32-bit integer for both Nvidia and AMD platforms. If, however, a 64-bit integer is passed to the function, higher bits will be truncated!!! The solution is to explicitly cast the 64-bit integer to bool, which is then implicitly cast to int.

Lo Wang’s fortune cookie quotes

    • You are not illiterate.
    • Confucius say it is easy to hate and difficult to love. Frankie say relax.
    • Thank you Lo Wang! But your fortune is in another cookie!
    • What’s a seven-letter word for ‘cryptic’?
    • Live each day like it’s your last. Or at least today, because… Oh I don’t want to spoil it.
    • Light travels faster than sound. That’s why some people look brilliant, until you hear them speak.
    • Whoever coined the phrase ‘quiet as a mouse’ never stepped on one.
    • Help! I am being held prisoner in a video game factory.
    • Don’t sweat the petty things and don’t pet the sweaty things. – George Carlin
    • You’re never too old to learn something stupid.
    • All men eat, but Fu Man Chu.
    • Some mistakes are too fun to make only once.
    • With sufficient thrust, pigs fly just fine.
    • He who takes advice from a cookie is sure to crumble.
    • You will stop procrastinating. Later.
    • Cardboard belt is a waist of paper.
    • The difference between an oral thermometer and a rectal thermometer is all a matter of taste.
    • You don’t need a parachute to skydive. You need a parachute to skydive twice.
    • Laugh and the world laughs with you. Cry and the world laughs at you.
    • That’s what ki said.
    • The good news: you’re not paranoid. The bad news: everyone is actually trying to kill you.
    • The early bird gets the worm. The second mouse gets cheese.
    • Small cookies bring great joy.
    • Time is an illusion. Lunchtime doubly so.
    • To be is to do. – Socrates
      To do is to be. – Sarte
      Do be do be do. – Sinatra
    • It is better to have loved and lost than to have had loved and gotten syphilis.
    • Cookie monster wasn’t here.
    • Chew, or chew not. There is no pie.
    • To maintain perfect accuracy, shoot first and call whatever you hit the target.
    • Information is not knowledge. Knowledge is not wisdom. Wisdom is not truth. Truth is not beauty. Beauty is not love. Love is not music. Music is the best. – FZ
    • Man who stand on toilet, high on pot.
    • It is better to have loved and lost than to have loved and got syphilis.

 

Reference: Shadow Warrior (2013)

Nvidia and Intel both make me furious

Nvidia: Hey, we have now started supporting icc 17.0 since cuda 9.0, but we won’t tell you that this is what you would end up having for your c++11 code:

nvcc warning : The -std=c++11 flag is not supported with the configured host compiler. Flag will be ignored.

Intel: Hey, just want to let you know that we have removed support for Knights Corner accelerators since icc 18. Now you either keep using older icc, or buy a brand new server with our brand new Knights Landing CPU.

And AMD: Sorry that Vega is a let-down, but hey, ours are cheaper!

 

The legend continues

qwc_top_banner

Day 1 is pretty disappointing. rapha lost to cooller without landing a single round; Team Liquid was stomped by 2z; Quakecon venue lost internet connection.

Day 2 is full of amazing matches. rapha managed to win two matches in group stage, and then survived Raisy scare. However, in the quarter final, he lost to his self-effacing teammate dahang. I root for rapha, and hope he will come back stronger next year. cooller continued his invincible state, until surprisingly thwarted by the young talent clawz in the semi final.

Final day, clawz is remembered forever in quake history  as the first player to win the championship of both duel and sacrifice. Everybody was awed, mouth agape. Also being remembered is clawz’s extreme bad manner towards Vo0 and the way he talked in his interview. Guess the kid has a lot to learn.

Witcher 3 tips

  • My favorite alchemy abilities
    • acquired tolerance
    • heightened tolerance
    • poisoned blades
  • My favorite decoction
    • ekhidna: actions consuming stamina increases vitality.
    • ancient leshen: sign cast increases stamina regeneration.
    • foglet: increase sign intensity in cloudy weather.
    • ekimmara: damages to foes increases vitality.
  • My favorite potion
    • tawny:  increase stamina regeneration speed. superior version never expires at night!
    • thunderbold: increase attack power.
    • golen oriole: immune to poison.
  • My favorite bomb:
    • devil’s puffball: releases poisonous gas. When used together with golen oriole, fight against a group of human enemies will become a piece of cake.
  • Other important tips
    • Burning and poison effect damages enemies by an amount proportional to their health.
    • Some monsters, such as werewolf, can regenerate vitality with great amount and fast pace. A green number rising above them indicates the recovered health. If further attack is found in vain, the player should not take this quest on the current level even if it is close to the suggested one. Simply level up and make the slash more deadly.

My 2017 wishes

  • CD Projekt Red releases gameplay clips of Cyberpunk 2077.
  • John Romero shows clips of Blackroom.
  • There is some news about Shadow of the Tomb Raider.
  • Flying wild hog shows something new, perhaps Shadow Warrior 3 WIP.
  • Unreal Engine supports runtime, per-camera near and far clip planes. (This has now come true for scene capture 2D!!)
  • The new AAA game Prey to be unlocked in May is not a letdown.
  • Valve crack down on cheaters in CS:GO.
  • Valve officially announce that Half Life 3 is an abandoned project.

Today’s PC games

How many times have we seen AAA games with upgraded graphics today turn out a pile of hyped garbage, a horrendous ripoff? To name a few of this year:

  • No man’s sky (perhaps the worst game, the most notorious scam of all time in human history)
  • Quantum break
  • The Deus Ex: Mankind Divided
  • Street Fighter V
  • Far Cry Primal

Behind these worthless craps are game studios who are only here to siphon off hard-earned money from us gamers ruthlessly and rabidly, and do not give a single damn about their games.

Fortunately, Polish game studios are an exception, an opposite. They care about us. Their games give me strength and warmth, and touch my soul.

  • Witcher by CD Projekt Red (Witcher 3: Wild Hunt is doubtless the best RPG game, a legendary masterpiece)
  • Shadow warrior by Flying Wild Hog

To toast Polish developers and designers, who restore my faith in humanity.