/*
 * Neuron.cpp
 *
 *  Created on: Jun 22, 2016
 *      Author: trabucco
 */

#include "Neuron.cuh"

long long Neuron::n = 0;

Neuron::Neuron(int nConnections) {
	activation = 0; activationPrime = 0;
	connections = nConnections;
	default_random_engine g(time(0) + (n++));
	normal_distribution<double> d(0, 1);
	weightedError = (double *)malloc(sizeof(double) * nConnections);
	weight = (double *)malloc(sizeof(double) * nConnections);
	impulse = (double *)calloc(nConnections, sizeof(double));
	for (int i = 0; i < connections; i++) {
		weight[i] = (d(g));
	}
}

Neuron::~Neuron() {}

__device__ double Neuron::sigmoid(double input) {
	return 1 / (1 + exp(-input));
}

__device__ double Neuron::sigmoidPrime(double input) {
	return sigmoid(input) * (1 - sigmoid(input));
}

__device__ double Neuron::activate(double input) {
	return tanh(input);
}

__device__ double Neuron::activatePrime(double input) {
	return (1 - (tanh(input) * tanh(input)));
}

__device__ double Neuron::forward(double *input) {
	double sum = 0;
	// find the weighted sum of all input
	for (int i = 0; i < connections; i++) {
		sum += input[i] * weight[i];
		//sum += input[i];
		//sum += weight[i];
	}// cout << " sum : " << sum << " weights : " << weight.size() << endl;
	activation = activate(sum);
	activationPrime = activatePrime(sum);
	return activation;
}

__device__ double *Neuron::backward(double errorPrime, double learningRate) {
	// update all weights
	for (int i = 0; i < connections; i++) {
		weightedError[i] = (errorPrime * weight[i] * activationPrime);
		weight[i] -= learningRate * errorPrime * impulse[i];
	}
	return weightedError;
}

Neuron *Neuron::copyToGPU(Neuron *data) {
	Neuron *neuron;
	cudaMalloc((void **)&neuron, (sizeof(Neuron)));
	cudaDeviceSynchronize();
	cudaMemcpy(neuron, data, sizeof(Neuron), cudaMemcpyHostToDevice);
	cudaDeviceSynchronize();

	double *e;
	double *w;
	double *i;
	cudaMalloc((void **)&e, (sizeof(double) * data->connections));
	cudaMalloc((void **)&w, (sizeof(double) * data->connections));
	cudaMalloc((void **)&i, (sizeof(double) * data->connections));
	cudaDeviceSynchronize();

	cudaMemcpy(e, data->weightedError, (sizeof(double) * data->connections), cudaMemcpyHostToDevice);
	cudaMemcpy(w, data->weight, (sizeof(double) * data->connections), cudaMemcpyHostToDevice);
	cudaMemcpy(i, data->impulse, (sizeof(double) * data->connections), cudaMemcpyHostToDevice);
	cudaDeviceSynchronize();

	cudaMemcpy(&(neuron->weightedError), &e, sizeof(double *), cudaMemcpyHostToDevice);
	cudaMemcpy(&(neuron->weight), &w, sizeof(double *), cudaMemcpyHostToDevice);
	cudaMemcpy(&(neuron->impulse), &i, sizeof(double *), cudaMemcpyHostToDevice);
	cudaDeviceSynchronize();

	return neuron;
}

Neuron *Neuron::copyFromGPU(Neuron *data) {
	Neuron *neuron;
	neuron = (Neuron *)malloc((sizeof(Neuron)));
	cudaDeviceSynchronize();
	cudaMemcpy(neuron, data, sizeof(Neuron), cudaMemcpyDeviceToHost);
	cudaDeviceSynchronize();

	double *e;
	double *w;
	double *i;
	e = (double *)malloc(sizeof(double) * neuron->connections);
	w = (double *)malloc(sizeof(double) * neuron->connections);
	i = (double *)malloc(sizeof(double) * neuron->connections);
	cudaDeviceSynchronize();

	cudaMemcpy(e, neuron->weightedError, (sizeof(double) * neuron->connections), cudaMemcpyDeviceToHost);
	cudaMemcpy(w, neuron->weight, (sizeof(double) * neuron->connections), cudaMemcpyDeviceToHost);
	cudaMemcpy(i, neuron->impulse, (sizeof(double) * neuron->connections), cudaMemcpyDeviceToHost);
	cudaDeviceSynchronize();

	memcpy(&(neuron->weightedError), &e, sizeof(double *));
	memcpy(&(neuron->weight), &w, sizeof(double *));
	memcpy(&(neuron->impulse), &i, sizeof(double *));
	cudaDeviceSynchronize();

	return neuron;
}


	.file	"tmpxft_00304094_00000000-6_Neuron.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4735:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4735:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.globl	_ZN6NeuronD2Ev
	.type	_ZN6NeuronD2Ev, @function
_ZN6NeuronD2Ev:
.LFB4723:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE4723:
	.size	_ZN6NeuronD2Ev, .-_ZN6NeuronD2Ev
	.globl	_ZN6NeuronD1Ev
	.set	_ZN6NeuronD1Ev,_ZN6NeuronD2Ev
	.align 2
	.globl	_ZN6Neuron7sigmoidEd
	.type	_ZN6Neuron7sigmoidEd, @function
_ZN6Neuron7sigmoidEd:
.LFB4725:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE4725:
	.size	_ZN6Neuron7sigmoidEd, .-_ZN6Neuron7sigmoidEd
	.align 2
	.globl	_ZN6Neuron12sigmoidPrimeEd
	.type	_ZN6Neuron12sigmoidPrimeEd, @function
_ZN6Neuron12sigmoidPrimeEd:
.LFB5441:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE5441:
	.size	_ZN6Neuron12sigmoidPrimeEd, .-_ZN6Neuron12sigmoidPrimeEd
	.align 2
	.globl	_ZN6Neuron8activateEd
	.type	_ZN6Neuron8activateEd, @function
_ZN6Neuron8activateEd:
.LFB5443:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE5443:
	.size	_ZN6Neuron8activateEd, .-_ZN6Neuron8activateEd
	.align 2
	.globl	_ZN6Neuron13activatePrimeEd
	.type	_ZN6Neuron13activatePrimeEd, @function
_ZN6Neuron13activatePrimeEd:
.LFB5445:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE5445:
	.size	_ZN6Neuron13activatePrimeEd, .-_ZN6Neuron13activatePrimeEd
	.align 2
	.globl	_ZN6Neuron7forwardEPd
	.type	_ZN6Neuron7forwardEPd, @function
_ZN6Neuron7forwardEPd:
.LFB4729:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE4729:
	.size	_ZN6Neuron7forwardEPd, .-_ZN6Neuron7forwardEPd
	.align 2
	.globl	_ZN6Neuron8backwardEdd
	.type	_ZN6Neuron8backwardEdd, @function
_ZN6Neuron8backwardEdd:
.LFB4730:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE4730:
	.size	_ZN6Neuron8backwardEdd, .-_ZN6Neuron8backwardEdd
	.align 2
	.globl	_ZN6Neuron9copyToGPUEPS_
	.type	_ZN6Neuron9copyToGPUEPS_, @function
_ZN6Neuron9copyToGPUEPS_:
.LFB4731:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$48, %esi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdi, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	leaq	16(%rsp), %r13
	call	cudaMalloc@PLT
	leaq	24(%rsp), %r12
	leaq	32(%rsp), %rbp
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$48, %edx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movslq	40(%rbx), %rsi
	movq	%r13, %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	40(%rbx), %rsi
	movq	%r12, %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	movslq	40(%rbx), %rsi
	movq	%rbp, %rdi
	salq	$3, %rsi
	call	cudaMalloc@PLT
	call	cudaDeviceSynchronize@PLT
	movslq	40(%rbx), %rdx
	movq	(%rbx), %rsi
	movl	$1, %ecx
	movq	16(%rsp), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	40(%rbx), %rdx
	movq	8(%rbx), %rsi
	movl	$1, %ecx
	movq	24(%rsp), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	40(%rbx), %rdx
	movq	16(%rbx), %rsi
	movl	$1, %ecx
	movq	32(%rsp), %rdi
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rsi
	movl	$8, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rax
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$8, %edx
	leaq	8(%rax), %rdi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rax
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$8, %edx
	leaq	16(%rax), %rdi
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rax
	movq	40(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4731:
	.size	_ZN6Neuron9copyToGPUEPS_, .-_ZN6Neuron9copyToGPUEPS_
	.align 2
	.globl	_ZN6Neuron11copyFromGPUEPS_
	.type	_ZN6Neuron11copyFromGPUEPS_, @function
_ZN6Neuron11copyFromGPUEPS_:
.LFB4732:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdi, %rbp
	movl	$48, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rax
	.cfi_def_cfa_offset 48
	call	malloc@PLT
	movq	%rax, %rbx
	call	cudaDeviceSynchronize@PLT
	movq	%rbp, %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$48, %edx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movslq	40(%rbx), %rbp
	salq	$3, %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rax, %rbp
	call	cudaDeviceSynchronize@PLT
	movslq	40(%rbx), %rdx
	movq	(%rbx), %rsi
	movq	%r13, %rdi
	movl	$2, %ecx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	40(%rbx), %rdx
	movq	8(%rbx), %rsi
	movq	%r12, %rdi
	movl	$2, %ecx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	movslq	40(%rbx), %rdx
	movq	16(%rbx), %rsi
	movq	%rbp, %rdi
	movl	$2, %ecx
	salq	$3, %rdx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movq	%r13, (%rbx)
	movq	%r12, 8(%rbx)
	movq	%rbp, 16(%rbx)
	call	cudaDeviceSynchronize@PLT
	popq	%rdx
	.cfi_def_cfa_offset 40
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4732:
	.size	_ZN6Neuron11copyFromGPUEPS_, .-_ZN6Neuron11copyFromGPUEPS_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4758:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE4758:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_,"axG",@progbits,_ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_,comdat
	.weak	_ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	.type	_ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_, @function
_ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_:
.LFB5399:
	.cfi_startproc
	endbr64
	imulq	$16807, (%rdi), %rax
	movl	$2147483647, %ecx
	xorl	%edx, %edx
	divq	%rcx
	movq	%rdx, %rax
	decq	%rax
	js	.L24
	cvtsi2sdq	%rax, %xmm0
	jmp	.L25
.L24:
	movq	%rax, %rcx
	andl	$1, %eax
	shrq	%rcx
	orq	%rax, %rcx
	cvtsi2sdq	%rcx, %xmm0
	addsd	%xmm0, %xmm0
.L25:
	imulq	$16807, %rdx, %rax
	movl	$2147483647, %ecx
	xorps	%xmm1, %xmm1
	xorl	%edx, %edx
	addsd	%xmm1, %xmm0
	divq	%rcx
	movq	%rdx, (%rdi)
	decq	%rdx
	js	.L26
	cvtsi2sdq	%rdx, %xmm1
	jmp	.L27
.L26:
	movq	%rdx, %rax
	andl	$1, %edx
	shrq	%rax
	orq	%rdx, %rax
	cvtsi2sdq	%rax, %xmm1
	addsd	%xmm1, %xmm1
.L27:
	mulsd	.LC2(%rip), %xmm1
	addsd	%xmm1, %xmm0
	divsd	.LC3(%rip), %xmm0
	comisd	.LC4(%rip), %xmm0
	jb	.L23
	movsd	.LC0(%rip), %xmm0
.L23:
	ret
	.cfi_endproc
.LFE5399:
	.size	_ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_, .-_ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	.text
	.align 2
	.globl	_ZN6NeuronC2Ei
	.type	_ZN6NeuronC2Ei, @function
_ZN6NeuronC2Ei:
.LFB4720:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movslq	%esi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdi, %rbx
	leaq	0(,%rbp,8), %r12
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movl	%ebp, 40(%rdi)
	movq	$0x000000000, 24(%rdi)
	movq	$0x000000000, 32(%rdi)
	xorl	%edi, %edi
	call	time@PLT
	movq	_ZN6Neuron1nE(%rip), %rdx
	movq	%r12, %rdi
	leaq	1(%rdx), %rcx
	addq	%rdx, %rax
	xorl	%edx, %edx
	movq	%rcx, _ZN6Neuron1nE(%rip)
	movl	$2147483647, %ecx
	divq	%rcx
	movl	$1, %eax
	testq	%rdx, %rdx
	cmove	%rax, %rdx
	movq	%rdx, 32(%rsp)
	call	malloc@PLT
	movq	%r12, %rdi
	movq	%rax, (%rbx)
	call	malloc@PLT
	movq	%rbp, %rdi
	movl	$8, %esi
	xorl	%ebp, %ebp
	movq	%rax, 8(%rbx)
	movq	%rax, %r12
	call	calloc@PLT
	xorps	%xmm0, %xmm0
	movq	%rax, 16(%rbx)
	xorl	%eax, %eax
.L31:
	cmpl	%ebp, 40(%rbx)
	jle	.L41
	testb	%al, %al
	jne	.L37
.L39:
	leaq	32(%rsp), %r13
	movq	%r13, %rdi
	call	_ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	movq	%r13, %rdi
	addsd	%xmm0, %xmm0
	subsd	.LC4(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)
	call	_ZSt18generate_canonicalIdLm53ESt26linear_congruential_engineImLm16807ELm0ELm2147483647EEET_RT1_
	movsd	8(%rsp), %xmm2
	addsd	%xmm0, %xmm0
	mulsd	%xmm2, %xmm2
	movaps	%xmm0, %xmm1
	subsd	.LC4(%rip), %xmm1
	movaps	%xmm1, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	%xmm0, %xmm2
	comisd	.LC4(%rip), %xmm2
	ja	.L39
	xorps	%xmm0, %xmm0
	ucomisd	%xmm0, %xmm2
	jp	.L38
	je	.L39
.L38:
	movaps	%xmm2, %xmm0
	movsd	%xmm1, 24(%rsp)
	movsd	%xmm2, 16(%rsp)
	call	log@PLT
	mulsd	.LC5(%rip), %xmm0
	movsd	16(%rsp), %xmm2
	divsd	%xmm2, %xmm0
	call	sqrt@PLT
	movsd	8(%rsp), %xmm2
	movsd	24(%rsp), %xmm1
	movb	$1, %al
	mulsd	%xmm0, %xmm2
	mulsd	%xmm1, %xmm0
	jmp	.L32
.L37:
	movaps	%xmm0, %xmm2
	xorl	%eax, %eax
.L32:
	xorps	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%r12,%rbp,8)
	incq	%rbp
	movaps	%xmm2, %xmm0
	jmp	.L31
.L41:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L36
	call	__stack_chk_fail@PLT
.L36:
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4720:
	.size	_ZN6NeuronC2Ei, .-_ZN6NeuronC2Ei
	.globl	_ZN6NeuronC1Ei
	.set	_ZN6NeuronC1Ei,_ZN6NeuronC2Ei
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	_ZN6Neuron1nE
	.bss
	.align 8
	.type	_ZN6Neuron1nE, @object
	.size	_ZN6Neuron1nE, 8
_ZN6Neuron1nE:
	.zero	8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	-1
	.long	1072693247
	.align 8
.LC2:
	.long	-8388608
	.long	1105199103
	.align 8
.LC3:
	.long	-16777216
	.long	1137704959
	.align 8
.LC4:
	.long	0
	.long	1072693248
	.align 8
.LC5:
	.long	0
	.long	-1073741824
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

/*
 * Neuron.h
 *
 *  Created on: Jun 22, 2016
 *      Author: trabucco
 */

#ifndef NEURON_H_
#define NEURON_H_

#include <math.h>
#include <vector>
#include <time.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <random>
#include <hip/hip_runtime.h>
using namespace std;

class Neuron {
private:
	static long long n;
	__device__ double sigmoid(double input);
	__device__ double sigmoidPrime(double input);
	__device__ double activate(double input);
	__device__ double activatePrime(double input);
public:
	double *weightedError;
	double *weight;
	double *impulse;
	double activation;
	double activationPrime;
	int connections;
	Neuron(int nConnections);
	~Neuron();
	__device__ double forward(double *input);
	__device__ double *backward(double errorPrime, double learningRate);
	static Neuron *copyToGPU(Neuron *data);
	static Neuron *copyFromGPU(Neuron *data);
};

#endif /* NEURON_H_ */

	.text
	.file	"Neuron.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
