Warning, /DataFormats/DetId/test/test_detid.cu is written in an unsupported language. File is not indexed.
0001 #include <cassert>
0002 #include <iostream>
0003
0004 #include <cuda.h>
0005 #include <cuda_runtime.h>
0006
0007 #include "DataFormats/DetId/interface/DetId.h"
0008 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0009 #include "HeterogeneousCore/CUDAUtilities/interface/requireDevices.h"
0010
0011 __global__ void test_gen_detid(DetId* id, uint32_t const rawid) {
0012 DetId did{rawid};
0013 *id = did;
0014 }
0015
0016 void test_detid() {
0017 // test det ids
0018 DetId h_id, h_id_test{100};
0019 DetId h_test0{1};
0020 DetId* d_id;
0021
0022 cudaMalloc((void**)&d_id, sizeof(DetId));
0023 cudaMemcpy(d_id, &h_id, sizeof(DetId), cudaMemcpyHostToDevice);
0024 test_gen_detid<<<1, 1>>>(d_id, 100);
0025 cudaMemcpy(&h_id, d_id, sizeof(DetId), cudaMemcpyDeviceToHost);
0026
0027 assert(h_id_test == h_id);
0028 assert(h_id != h_test0);
0029 }
0030
0031 int main(int argc, char** argv) {
0032 cms::cudatest::requireDevices();
0033
0034 // test det id functionality
0035 test_detid();
0036 }