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
int compute_blocks(int length, int threads_per_block) { | |
//integer division: | |
//if length is evenly divisable by the number of threads | |
//is equivalent to length / threads_per_block, if not | |
//it is equivalent to length / threads_per_block + 1 | |
return (length + threads_per_block - 1) / threads_per_block; | |
} | |
dim3 compute_blocks(int xsize, int ysize, int zsize, | |
int threads_per_block_x, |
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
1) get OSXFuse: http://osxfuse.github.com | |
2) create local folder to mount remote fs into | |
3) invoke sshfs: | |
sshfs user@server:/home/user/ ~/remote -oauto_cache,reconnect,defer_permissions,negative_vncache,volname=RemoteHome | |
Look here for additional information: | |
http://www.read-write.fr/blog/blog/2012/02/26/my-guide-for-sshfs/ |
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
//Author: Ugo Varetto | |
// | |
//function objects do not allow a call to the object's operator()(...) | |
//without an explicit creation: | |
// struct neg { | |
// int operator()(int i) const { return -i; } | |
// }; | |
// neg n; | |
// std::cout << n(4) << std::endl | |
// or, if the () operator is const |
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
env | grep SLURM_JOB_NODELIST | grep -P -o "\d+" |
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 <iostream> | |
#include <cuda_runtime.h> | |
class CClass { | |
public: | |
class Inner { | |
public: | |
__host__ __device__ Inner() : value_( 5 ) {} | |
__host__ __device__ Inner( const Inner& i ) : value_( 9 * i.value_ ) {} | |
__host__ __device__ int value() const { return value_; } |
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 <vector> | |
#include <stdexcept> | |
#ifdef __APPLE__ | |
#include <OpenGL/OpenGL.h> | |
#else | |
#ifdef WIN32 | |
#include <wingdi.h> | |
#else | |
#include <GL/glx.h> |
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
/* | |
* Author: Ugo Varetto - ugovaretto@gmail.com | |
* This code is distributed under the terms of the Apache Software License version 2.0 | |
* https://opensource.org/licenses/Apache-2.0 | |
*/ | |
#include < time.h > | |
#include < windows.h > | |
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) |
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 <iostream> | |
#include <iomanip> | |
#include <chrono> | |
int main(int, char**) { | |
std::chrono::time_point< std::chrono::system_clock> tp; | |
tp = std::chrono::system_clock::now(); | |
const std::time_t t = std::chrono::system_clock::to_time_t(tp); | |
std::cout << asctime(localtime(&t)) << std::endl; | |
return 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
//FROM STACKOVERFLOW: http://stackoverflow.com/questions/275004/c-timer-function-to-provide-time-in-nano-seconds | |
inline __int64 GetCpuClocks() | |
{ | |
// Counter | |
struct { int32 low, high; } counter; | |
// Use RDTSC instruction to get clocks count | |
__asm push EAX | |
__asm push EDX |
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 <iostream> | |
struct B1 { | |
B1(int) {} | |
int Get() const { return 1; } | |
}; | |
struct B2 { | |
B2(int) {} | |
int Get() const { return 2; } | |
}; |