Skip to content

Instantly share code, notes, and snippets.

module priority_select #(
parameter N = 16 // any positive integer
) (
input wire [N-1:0] req,
output wire [N-1:0] gnt
);
generate
if (N == 1) begin: base_case0
assign gnt = req;
@timshen91
timshen91 / gist:9ba7612f877839cdd346199e22efca6a
Last active March 3, 2022 19:26
Benchmarking Turing MMA instructions
#include <cuda.h>
#include <cuda_fp16.h>
__device__ inline void mma_fp16_acc_fp16(unsigned const *A, unsigned const *B,
unsigned const *C, unsigned *D) {
asm volatile(
"mma.sync.aligned.m16n8k8.row.col.f16.f16.f16.f16 {%0,%1}, "
"{%2,%3}, {%4}, {%5,%6};\n"
: "=r"(D[0]), "=r"(D[1])
: "r"(A[0]), "r"(A[1]), "r"(B[0]), "r"(C[0]), "r"(C[1]));
@Brainiarc7
Brainiarc7 / build-tensorflow-from-source.md
Last active July 29, 2023 21:28
Build Tensorflow from source, for better performance on Ubuntu.

Building Tensorflow from source on Ubuntu 16.04LTS for maximum performance:

TensorFlow is now distributed under an Apache v2 open source license on GitHub.

On Ubuntu 16.04LTS+:

Step 1. Install NVIDIA CUDA:

To use TensorFlow with NVIDIA GPUs, the first step is to install the CUDA Toolkit as shown:

@SergNikitin
SergNikitin / ptr_cast.cpp
Created September 6, 2016 08:53
std::unique_ptr cast helpers
/**
* @brief Converts std::unique_ptr of base type to std::unique_ptr of derived type
* by using static_cast internally
* @details Ownership of the object is transfered to the returned std::unique_ptr.
* It is somewhat analogous to std::static_ptr_cast
*/
template<typename Derived, typename Base, typename Deleter>
std::unique_ptr<Derived, Deleter> static_ptr_cast(std::unique_ptr<Base, Deleter> base)
{
auto deleter = base.get_deleter();
@hi2p-perim
hi2p-perim / dynamiccastunique.cpp
Created March 22, 2015 17:37
dynamic_cast with unique_ptr
#include <iostream>
#include <memory>
struct A
{
virtual ~A() {}
};
struct B : public A
{
The USB Blaster udev rules on the Altera website
( http://www.altera.com/download/drivers/dri-usb_b-lnx.html )
did not work for me on Debian Jessie/Sid. A modified version of the file, listed below, works for me
(this is the contents of /etc/udev/rules.d/51-usbblaster.rules ). After restarting udev
(`sudo service udev restart`) I was able to program the DE0-Nano.
# USB-Blaster
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6002", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6003", MODE="0666", GROUP="plugdev"
@allanmac
allanmac / sha256.cu
Last active November 10, 2023 01:26
A CUDA SHA-256 subroutine using macro expansion
// -*- compile-command: "nvcc -m 32 -arch sm_35 -Xptxas=-v,-abi=no -cubin sha256.cu"; -*-
//
// Copyright 2013 Allan MacKinnon <allanmac@alum.mit.edu>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to