Skip to content

Instantly share code, notes, and snippets.

View bridgesign's full-sized avatar

Rohan Patil bridgesign

View GitHub Profile
@bridgesign
bridgesign / BiCGSTAB.py
Last active February 29, 2024 14:37
BiCGSTAB or BCGSTAB Pytorch implementation GPU support
import torch
import warnings
class BiCGSTAB():
"""
This is a pytorch implementation of BiCGSTAB or BCGSTAB, a stable version
of the CGD method, published first by Van Der Vrost.
For solving ``Ax = b`` system.
@bridgesign
bridgesign / perceptron_visualization.ipynb
Created November 15, 2020 13:44
Perceptron_visualization.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bridgesign
bridgesign / generator_class.py
Created July 21, 2020 21:21
GIst for Simple RTB Game
class generator:
"""
The generator creates a single ad slot with a random user and
makes the bidders to bid for the slot. Depending on the result,
it sends back the result to the individual bidders.
"""
def __init__(self, users, bidders):
self.users = users
self.bidders = bidders
self.bidders_num = len(bidders)
@bridgesign
bridgesign / bidder_sim.ipynb
Last active July 21, 2020 21:17
Gist for Simple RTB Game
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bridgesign
bridgesign / bidder_class.py
Last active July 21, 2020 21:07
Gist for Simple RTB Game
class bidmodel(nn.Module):
"""
This defines the neural model used by the bidder
It gives teo vectors as output. The first is the vectors
of bids and the second the probability of click vector over
all the ads the bidder owns.
"""
def __init__(self, size, cuda=True):
super(bidmodel, self).__init__()
@bridgesign
bridgesign / user_class.py
Last active July 21, 2020 21:05
Gist for Simple RTB Game
class user:
"""
The user class defines a user which are a part of the game
It keeps the views and clicks vector for all the ads and shares the
data to the bidder only about the ads the bidder owns
It also determines whether it will see the ad or not depending on
the overall clicks and views of all ads.
It also updates the vectors based on the view and click. The data about
@bridgesign
bridgesign / getreadcount_system_call.md
Last active June 15, 2024 04:03
Creating a system call in xv6 for keeping count of read syscalls on per prcoess basis

Constructing a System call that gives the count of how many times System call Read was called.

We will be using xv6 OS for this exercise. In this exercise, we will construct a system call that can give read counts on per process basis and then modify it to obtain a system call that will give read counts of all processes since the start of kernel.

Adding the counter

To add a system call that can get the number of times the system call 'read' was used in a specific program, we require to make a variable that stores this count for each process.

So, we first start by looking at the files proc.c and proc.h
These files are associated with creating a process. We need to store the count on a per process basis so we will have to add something to the structure that is created for a process.
For that, open proc.h. In this file, the structure for a process is defined. Find struct proc and then add an integer to keep account for the read calls. eg. int readid;

@bridgesign
bridgesign / mem_policy_analysis.ipynb
Last active February 29, 2020 04:45
Simulation of different cache replacement policies
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bridgesign
bridgesign / wgrep.c
Last active February 29, 2020 04:43
This is wgrep
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#define _GNU_SOURCE
void grep(int file, const char *pattern){
@bridgesign
bridgesign / wcat.c
Last active February 29, 2020 04:43
This is wcat
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char const *argv[])