<commit_before>#include "cufunc.h"
#include <string.h>
#include "mrc.h"
#include "func.h"
#include <signal.h> 
#define PI 3.141592653589793
#define BLOCKSIZE 1024


static __device__ cuComplex conj(cuComplex f)
{
	f.y*=-1.0;
	return f;
}


static __device__ cuComplex cXc(cuComplex a, cuComplex b) // a*b
{
	cuComplex c;
	c.x=a.x*b.x-a.y*b.y;
	c.y=a.x*b.y+a.y*b.x;
	return c;
}

static __device__ float cabs(cuComplex a) // a*b
{
	return sqrt(a.x*a.x+a.y*a.y);
}

bool initGPU(int GPUNum)
{
	//initional CUDA device
	int ngpu;
	cudaGetDeviceCount(&ngpu);
	if(ngpu <= 0)
	{
		return false;
	}
	if(GPUNum>=ngpu)
	{
		printf("GPU ID %d is out of range(%d). Abort.\n",GPUNum,ngpu);
		return false;
	}

	cudaDeviceProp prop;
	if(cudaGetDeviceProperties(&prop, GPUNum) == cudaSuccess) 
	{
		printf("Use GPU: #%d %s\n",GPUNum,prop.name);
		if(prop.kernelExecTimeoutEnabled)
		{
			printf("Warnning: This GPU is also used for display, may not stable.\n");
		}
	}


	if(cudaSetDevice(GPUNum)!=cudaSuccess)
	{
		printf("Error: Failed to set CUDA Device #%d. Abort.\n",GPUNum);
		return false;
	}
	<commit_msg>Using argument '-gpu -1' will search for the first available/unused GPU. (at least when gpu are used exclusively which can be set by   nvidia-smi --compute-mode=EXCLUSIVE_PROCESS ) This is useful if a multi-GPU node is shared among multiple users, like in a High-Performance Computing cluster.<commit_after>#include "cufunc.h"
#include <string.h>
#include "mrc.h"
#include "func.h"
#include <signal.h> 
#define PI 3.141592653589793
#define BLOCKSIZE 1024


static __device__ cuComplex conj(cuComplex f)
{
	f.y*=-1.0;
	return f;
}


static __device__ cuComplex cXc(cuComplex a, cuComplex b) // a*b
{
	cuComplex c;
	c.x=a.x*b.x-a.y*b.y;
	c.y=a.x*b.y+a.y*b.x;
	return c;
}

static __device__ float cabs(cuComplex a) // a*b
{
	return sqrt(a.x*a.x+a.y*a.y);
}

bool initGPU(int GPUNum)
{
	//initional CUDA device
	int ngpu;
	cudaGetDeviceCount(&ngpu);
	if(ngpu <= 0)
	{
		return false;
	}

	cudaError_t status;
	if (GPUNum < 0) {
		// loop through all devices and use first available one.
		for (GPUNum=0; GPUNum<ngpu; GPUNum++) {
			status = cudaSetDevice(GPUNum);
			if (status == cudaSuccess) break;
		}
	}
	else if (GPUNum < ngpu) {
		status = cudaSetDevice(GPUNum);
	}
	else {
		printf("GPU ID %d is out of range(%d). Abort.\n",GPUNum,ngpu);
		return false;
	}

	if (status == cudaSuccess) {
		cudaDeviceProp prop;
		if (cudaGetDeviceProperties(&prop, GPUNum) == cudaSuccess) {
			if(prop.kernelExecTimeoutEnabled) {
				printf("Warnning: This GPU is also used for display, may not stable.\n");
			}
		}
	}

{'fraction_non_alphanumeric': 0.14735226400613968, 'fraction_numerical': 0.018802762854950115, 'mean_word_length': 3.845724907063197, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686741', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1085, 'n_words': 265}