This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <thrust/device_vector.h> | |
#include <thrust/sequence.h> | |
__global__ | |
void warpSum(int *data) { | |
int idx = blockIdx.x * blockDim.x + threadIdx.x; | |
int value = data[idx]; | |
#pragma unroll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select k-th (from LSB) radix of the number. | |
// Author: dfukunaga (https://github.com/dfukunaga) | |
int radix1bit(int number, int k) { | |
return (number >> k) & 0b1; | |
} | |
int radix4bit(int number, int k) { | |
return (number >> (k << 2)) & 0xF; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cuda_runtime_api.h> | |
#include <cudpp_hash.h> | |
int main() { | |
const int N = 10; | |
// ハッシュテーブルに格納するデータ | |
int keys[N] = {1, 6, 4, 9, 0, 3, 7, 2, 5, 8}; | |
int vals[N] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
: $1 $2 | |
LOCAL_IP=$1 | |
REMOTE_IP=$2 | |
set -o pipefail | |
INITIAL_CLUSTER=$( \ | |
curl -s http://${REMOTE_IP}:2379/v2/members \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
: $1 | |
LOCAL_IP=$1 | |
./etcd --name ${LOCAL_IP} \ | |
--initial-advertise-peer-urls http://${LOCAL_IP}:2380 \ | |
--listen-peer-urls http://0.0.0.0:2380 \ | |
--advertise-client-urls http://${LOCAL_IP}:2379 \ | |
--listen-client-urls http://0.0.0.0:2379 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arpa/inet.h> | |
#include <netinet/in.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <string> | |
std::string get_src_addr_popen(const std::string& addr) { | |
// assemble command string | |
char command[64]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arpa/inet.h> | |
#include <netinet/in.h> | |
#include <sys/socket.h> | |
#include <string> | |
std::string get_local_addr(int sockfd) { | |
struct sockaddr_in sin; | |
socklen_t len = sizeof(sin); | |
int rc = getsockname(sockfd, (struct sockaddr*)&sin, &len); | |
if (rc != 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <zmq.h> | |
#include <chrono> | |
#include <iostream> | |
#include <string> | |
#include <thread> | |
int main(int argc, char** argv) { | |
if (argc != 3) { | |
std::cout << "Usage: " << argv[0] << " [type] [address]" << std::endl; | |
return 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <zmq.h> | |
#include <atomic> | |
#include <iostream> | |
#include <thread> | |
class socket_monitor { | |
public: | |
socket_monitor(void* ctx, void* socket) { | |
// Start monitoring | |
zmq_socket_monitor(socket, "inproc://monitor", ZMQ_EVENT_ALL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <zmq.h> | |
#include <atomic> | |
#include <chrono> | |
#include <iomanip> | |
#include <iostream> | |
#include <string> | |
#include <thread> | |
double elapsed() { | |
static auto begin = std::chrono::system_clock::now(); |