Commit 6bc7f344 authored by karius's avatar karius

security commit

parent d6e87cf0
/*
* AlignRMSD.cu
*
* Created on: Jul 4, 2019
* Author: kkarius
*/
#include <IMP/rmf/atom_io.h>
#include <RMF/FileHandle.h>
#include <RMF.h>
#include <IMP/flags.h>
#include <IMP/atom/pdb.h>
#include <IMP/rmf/frames.h>
#include <IMP/atom/force_fields.h>
#include <IMP/Model.h>
#include <string>
int main(){
std::string rmf_name = "/home/kkarius/junk/test_rmfs/run_109_frame_6963.rmf3";
RMF::FileHandle rmf_fh;
RMF::get_is_valid_key_name(rmf_name);
// IMP::Model m;
// int N = 256;
// int mx = 300;
// float xlen = 312.3f;
// float host_DSHIFT[sizeof(float) * 3];
// host_DSHIFT[0] = xlen / mx;
// host_DSHIFT[1] = xlen / mx;
// host_DSHIFT[2] = xlen / mx;
// float host_DSIZE[sizeof(int) * 3];
// host_DSIZE[0] = N;
// host_DSIZE[1] = N;
// host_DSIZE[2] = N;
// cudaMemcpyToSymbol(DSIZE, host_DSIZE, sizeof(int) * 3);
//TODO:sanity check on user inputs
// float data_R = 1.041f;
// float feat_R = 1.5f;
// int cutoff_sigma = 3;
// int charge = 6; //carbon
// size_t array_size = getSizeGaussian(feat_R, data_R, cutoff_sigma);
//TODO: sanity check on size
// float* gaussian;
// gaussian = (float *) malloc(array_size * sizeof(float));
// createGaussian(gaussian, feat_R, cutoff_sigma, charge, array_size);
// float h_data[3][3];
// for (int i = 0; i < 3; i++)
// for (int j = 0; j < 3; j++)
// h_data[i][j] = i * j;
// int size = width * height * sizeof(float);
// Allocate CUDA array in device memory
// cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 0, 0, 0,
// cudaChannelFormatKindFloat);
// cudaArray* cuArray;
// cudaMallocArray(&cuArray, &channelDesc, array_size);
// Copy to device memory some data located at address h_data
// in host memory
// cudaMemcpyToArray(cuArray, 0, 0, gaussian, array_size,
// cudaMemcpyHostToDevice);
// Set texture reference parameters
// texRef.addressMode[0] = cudaAddressModeWrap;
// texRef.addressMode[1] = cudaAddressModeWrap;
// texRef.filterMode = cudaFilterModeLinear;
// texRef.normalized = true;
//
// // Bind the array to the texture reference
// cudaBindTextureToArray(texRef, cuArray, channelDesc);
//
// float* host_output;
// host_output = (float *) malloc(N*N*N*sizeof(float));
// float* output;
// cudaMalloc(&output, N * N * N * sizeof(float));
//
// // Allocate result of transformation in device memory
// float* output;
// cudaMalloc(&output, width * height * sizeof(float));
//
// // Invoke kernel
// int total = N*N*N;
// int per_thread = N*16;
// int per_block = N*N*16;
// printf("Up to here\n");
// transformKernel<<<16, 256>>>(output,total,per_thread,per_block);
// printf("Even here\n");
//
// printf ("\n After operation \n ");
// for ( int i =0 ; i<3 ; i++ )
// {
// for ( int j = 0 ; j<3; j++ )
// printf ("%f ", h_data [i][j] );
//
// printf ("\n");
// }
//
// // Free device memory
// cudaFreeArray(cuArray);
// cudaMemcpy(host_output,output,total*sizeof(float),cudaMemcpyDeviceToHost);
// printf("And here\n");
// printf ("output[0]:%f\n",host_output[257]);
// printf("But not here\n");
// cudaFree(output);
// free(host_output);
}
/*
* AlignRMSD.cu
*
* Created on: Jul 4, 2019
* Author: kkarius
*/
#include <IMP/rmf/atom_io.h>
#include <RMF/FileHandle.h>
#include <RMF.h>
#include <RMF/internal/SharedData.h>
#include <RMF/internal/shared_data_factories.h>
#include <IMP/flags.h>
#include <IMP/atom/pdb.h>
#include <IMP/rmf/frames.h>
#include <IMP/atom/force_fields.h>
#include <IMP/Model.h>
#include <string>
int main(){
std::string rmf_name = "/home/kkarius/junk/test_rmfs/run_109_frame_6963.rmf3";
RMF::FileHandle rmf_fh;
RMF::internal::create_file(rmf_name);
// IMP::Model m;
// int N = 256;
// int mx = 300;
// float xlen = 312.3f;
// float host_DSHIFT[sizeof(float) * 3];
// host_DSHIFT[0] = xlen / mx;
// host_DSHIFT[1] = xlen / mx;
// host_DSHIFT[2] = xlen / mx;
// float host_DSIZE[sizeof(int) * 3];
// host_DSIZE[0] = N;
// host_DSIZE[1] = N;
// host_DSIZE[2] = N;
// cudaMemcpyToSymbol(DSIZE, host_DSIZE, sizeof(int) * 3);
//TODO:sanity check on user inputs
// float data_R = 1.041f;
// float feat_R = 1.5f;
// int cutoff_sigma = 3;
// int charge = 6; //carbon
// size_t array_size = getSizeGaussian(feat_R, data_R, cutoff_sigma);
//TODO: sanity check on size
// float* gaussian;
// gaussian = (float *) malloc(array_size * sizeof(float));
// createGaussian(gaussian, feat_R, cutoff_sigma, charge, array_size);
// float h_data[3][3];
// for (int i = 0; i < 3; i++)
// for (int j = 0; j < 3; j++)
// h_data[i][j] = i * j;
// int size = width * height * sizeof(float);
// Allocate CUDA array in device memory
// cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 0, 0, 0,
// cudaChannelFormatKindFloat);
// cudaArray* cuArray;
// cudaMallocArray(&cuArray, &channelDesc, array_size);
// Copy to device memory some data located at address h_data
// in host memory
// cudaMemcpyToArray(cuArray, 0, 0, gaussian, array_size,
// cudaMemcpyHostToDevice);
// Set texture reference parameters
// texRef.addressMode[0] = cudaAddressModeWrap;
// texRef.addressMode[1] = cudaAddressModeWrap;
// texRef.filterMode = cudaFilterModeLinear;
// texRef.normalized = true;
//
// // Bind the array to the texture reference
// cudaBindTextureToArray(texRef, cuArray, channelDesc);
//
// float* host_output;
// host_output = (float *) malloc(N*N*N*sizeof(float));
// float* output;
// cudaMalloc(&output, N * N * N * sizeof(float));
//
// // Allocate result of transformation in device memory
// float* output;
// cudaMalloc(&output, width * height * sizeof(float));
//
// // Invoke kernel
// int total = N*N*N;
// int per_thread = N*16;
// int per_block = N*N*16;
// printf("Up to here\n");
// transformKernel<<<16, 256>>>(output,total,per_thread,per_block);
// printf("Even here\n");
//
// printf ("\n After operation \n ");
// for ( int i =0 ; i<3 ; i++ )
// {
// for ( int j = 0 ; j<3; j++ )
// printf ("%f ", h_data [i][j] );
//
// printf ("\n");
// }
//
// // Free device memory
// cudaFreeArray(cuArray);
// cudaMemcpy(host_output,output,total*sizeof(float),cudaMemcpyDeviceToHost);
// printf("And here\n");
// printf ("output[0]:%f\n",host_output[257]);
// printf("But not here\n");
// cudaFree(output);
// free(host_output);
}
/*
* AlignRMSD.h
*
* Created on: Jul 4, 2019
* Author: kkarius
*/
#ifndef ALIGNRMSD_H_
#define ALIGNRMSD_H_
#include <magma.h>
class AlignRMSD {
public:
AlignRMSD();
virtual ~AlignRMSD();
};
#endif /* ALIGNRMSD_H_ */
......@@ -26,6 +26,7 @@
#define NZ 300
#define BATCH 1
#define NRANK 3
//
//cudaError_t PerfCuFFT(int argc, char **argv, cufftDoubleComplex *h_a) {
// cudaError_t cudaStatus;
......@@ -232,24 +233,6 @@ void CMrcReader::readHeader(std::string file_name) {
// cudaMemcpy(deviceInputImageData, data, image_width * image_height * sizeof(float), cudaMemcpyHostToDevice);
// cudaMemcpy(deviceMaskData, mask, MASK_WIDTH * MASK_WIDTH * sizeof(float), cudaMemcpyHostToDevice);
void CMrcReader::oink(std::string to){
std::cout << "Oink to " << to << "." << std::endl;
}
void CMrcReader::dataHostToDevice(std::string mrc_file_name,
float * deviceData) {
if (!x_HeaderRead) {
readHeader(mrc_file_name);
}
//replace this with pinned memory or something?
readData();
cudaMalloc((void **) &deviceData,
header.nx * header.ny * header.nz * sizeof(float));
cudaMemcpy(deviceData, pdata,
header.nx * header.ny * header.nz * sizeof(float),
cudaMemcpyHostToDevice);
purgeData();
}
void CMrcReader::readData() {
// * mode 0 -> int8
......@@ -265,15 +248,14 @@ void CMrcReader::readData() {
if (header.mode == 2) {
int volume = header.nx * header.ny * header.nz;
int bytes = sizeof(float) * volume;
data.resize(bytes);
pdata=(float*)malloc(bytes);
data = (float*) malloc(bytes);
std::fstream x_FileHandle;
x_FileHandle.open(mrc_file_name,
std::fstream::in | std::fstream::binary);
//jump header
x_FileHandle.seekg(1024, std::ios::beg);
x_FileHandle.read((char*) pdata, bytes);
x_FileHandle.read((char*) data, bytes);
// double sum = 0;
// for (int i = 0; i < bytes; i++) {
......@@ -308,10 +290,6 @@ void CMrcReader::readData() {
}
void CMrcReader::purgeData(void){
data.clear();
}
CMrcReader::~CMrcReader() {
// TODO Auto-generated destructor stub
}
......
......@@ -10,6 +10,8 @@
#include <string>
#include <vector>
#include <cuda_runtime.h>
#include <cuda.h>
//'?' boolean
//'b' (signed) byte
......@@ -129,20 +131,20 @@ struct SMrcHeader {
};
#pragma pack(pop, r1)
typedef unsigned char uchar ;
class CMrcReader {
public:
CMrcReader();
SMrcHeader header;
std::string mrc_file_name;
std::vector<float> data;
float * pdata;
float * data;
virtual ~CMrcReader();
void readHeader(std::string mrc_file_name);
void printHeader(std::string mrc_file_name);
void readData(void);
void purgeData(void);
void dataHostToDevice(std::string mrc_file_name,float * deviceData);
void oink(std::string to);
void writeDataToTexture(const textureReference * tex);
private:
bool x_HeaderRead = false;
};
......
No preview for this file type
No preview for this file type
This diff is collapsed.
......@@ -10,6 +10,7 @@
#include <CMrcReader.h>
#include <cuda_runtime.h>
#include <cuda.h>
#include <fstream>
#include <string>
#include <iostream>
......
CC=gcc
#CC=gcc
NVCC=nvcc
CFLAGS=-I. -I./cuda_util_include
LFLAGS=-L.
IMP_INCLUDE = -I/data/git/imp/bin/include/ -I/data/git/imp/build/src/dependency/RMF/include/
EIGEN_INCLUDE = -I/data/tools/eigen-eigen-323c052e1731/
CUDA_INCLUDE = -I./cuda_util_include #most of it comes with nvcc, this is a convenience lib
CFLAGS=-I. $(CUDA_INCLUDE) $(IMP_INCLUDE) $(EIGEN_INCLUDE) -D_GLIBCXX_USE_CXX11_ABI=0 #the latter is for IMP
BOOST_LINKS = -L/usr/local/lib -lboost_filesystem
IMP_LINKS = -L/data/git/imp/build/lib/ -lRMF -limp_core -limp_rmf -limp_kernel -limp_atom
LFLAGS=-L. $(IMP_LINKS) $(BOOST_LINKS)
all: CudaTest.cu CMrcReader.o
$(NVCC) $(LFLAGS) $(CFLAGS) -o CudaTest CudaTest.cu CMrcReader.o
......
No preview for this file type
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment