Calculate euclidean norm of a vector

I’m quite new to CUDA-programming and trying to compute the 2-Norm of a vector. I tried it with a selfwritten function, but here it seems that the threads are overwriting randomly the result (so each one reads out a value from the same variable and writes it back after addition).
There is the problem: How can I compute the norm for all elements in the vector without loosing the last results?

I also tried the cuBLAS-libraries, but all I get is 0 or a Segmentationfault, because I can’t find an example how to use cublasSnrm2 corectly. :(

Read the cuBLAS documentation, as that is probably one of the easier functions to call. you just need to create a handle and a status_t variable to use a parameters beforehand;

float history_s_norm=0.0f;
cur=cublasSnrm2_v2(handle,Acols,tempvecC,1,&history_s_norm);//get eucild norm of tempvecC
if(cur != CUBLAS_STATUS_SUCCESS){printf("error code %d, line(%d)\n", cur, __LINE__);exit(EXIT_FAILURE);}

It works, thanks! :)