mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
hdf5
This commit is contained in:
@@ -15385,6 +15385,14 @@ Tests under link:userland/libs[] require certain optional libraries to be instal
|
|||||||
|
|
||||||
See for example <<blas>>.
|
See for example <<blas>>.
|
||||||
|
|
||||||
|
===== HDF5
|
||||||
|
|
||||||
|
https://en.wikipedia.org/wiki/Hierarchical_Data_Format
|
||||||
|
|
||||||
|
Binary format to store data. TODO vs databases, notably SQLite: https://datascience.stackexchange.com/questions/262/hierarchical-data-format-what-are-the-advantages-compared-to-alternative-format
|
||||||
|
|
||||||
|
Examples: link:userland/libs/hdf5[]
|
||||||
|
|
||||||
=== Userland content filename conventions
|
=== Userland content filename conventions
|
||||||
|
|
||||||
The following basenames should always refer to programs that do the same thing, but in different languages:
|
The following basenames should always refer to programs that do the same thing, but in different languages:
|
||||||
|
|||||||
1
build
1
build
@@ -386,6 +386,7 @@ so looping over all of them would waste time.
|
|||||||
'libboost-all-dev',
|
'libboost-all-dev',
|
||||||
'libdrm-dev',
|
'libdrm-dev',
|
||||||
'libeigen3-dev',
|
'libeigen3-dev',
|
||||||
|
'libhdf5-dev',
|
||||||
'libopenblas-dev',
|
'libopenblas-dev',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
11
common.py
11
common.py
@@ -1750,19 +1750,26 @@ https://cirosantilli.com/linux-kernel-module-cheat#gem5-debug-build
|
|||||||
# Header only.
|
# Header only.
|
||||||
'cc_flags_after': [],
|
'cc_flags_after': [],
|
||||||
},
|
},
|
||||||
|
'hdf5': {
|
||||||
|
'pkg_config_id': 'hdf5-serial',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
package_key = dirpath_relative_root_components[2]
|
package_key = dirpath_relative_root_components[2]
|
||||||
if package_key in packages:
|
if package_key in packages:
|
||||||
package = packages[package_key]
|
package = packages[package_key]
|
||||||
else:
|
else:
|
||||||
package = {}
|
package = {}
|
||||||
|
if 'pkg_config_id' in package:
|
||||||
|
pkg_config_id = package['pkg_config_id']
|
||||||
|
else:
|
||||||
|
pkg_config_id = package_key
|
||||||
if 'cc_flags' in package:
|
if 'cc_flags' in package:
|
||||||
cc_flags.extend(package['cc_flags'])
|
cc_flags.extend(package['cc_flags'])
|
||||||
else:
|
else:
|
||||||
pkg_config_output = self.sh.check_output([
|
pkg_config_output = self.sh.check_output([
|
||||||
self.env['pkg_config'],
|
self.env['pkg_config'],
|
||||||
'--cflags',
|
'--cflags',
|
||||||
package_key
|
pkg_config_id
|
||||||
]).decode()
|
]).decode()
|
||||||
cc_flags.extend(self.sh.shlex_split(pkg_config_output))
|
cc_flags.extend(self.sh.shlex_split(pkg_config_output))
|
||||||
if 'cc_flags_after' in package:
|
if 'cc_flags_after' in package:
|
||||||
@@ -1771,7 +1778,7 @@ https://cirosantilli.com/linux-kernel-module-cheat#gem5-debug-build
|
|||||||
pkg_config_output = subprocess.check_output([
|
pkg_config_output = subprocess.check_output([
|
||||||
self.env['pkg_config'],
|
self.env['pkg_config'],
|
||||||
'--libs',
|
'--libs',
|
||||||
package_key
|
pkg_config_id
|
||||||
]).decode()
|
]).decode()
|
||||||
cc_flags_after.extend(self.sh.shlex_split(pkg_config_output))
|
cc_flags_after.extend(self.sh.shlex_split(pkg_config_output))
|
||||||
os.makedirs(os.path.dirname(out_path), exist_ok=True)
|
os.makedirs(os.path.dirname(out_path), exist_ok=True)
|
||||||
|
|||||||
@@ -696,6 +696,14 @@ path_properties_tuples = (
|
|||||||
{'requires_dynamic_library': True},
|
{'requires_dynamic_library': True},
|
||||||
{
|
{
|
||||||
'libdrm': {'requires_sudo': True},
|
'libdrm': {'requires_sudo': True},
|
||||||
|
'hdf5': (
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
'hello_cpp.cpp': {
|
||||||
|
'cc_flags_after': ['-lhdf5_cpp', LF],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'linux': (
|
'linux': (
|
||||||
|
|||||||
1
userland/libs/hdf5/README.adoc
Normal file
1
userland/libs/hdf5/README.adoc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
https://cirosantilli.com/linux-kernel-module-cheat#hdf5
|
||||||
1
userland/libs/hdf5/build
Symbolic link
1
userland/libs/hdf5/build
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../build
|
||||||
54
userland/libs/hdf5/hello_cpp.cpp
Normal file
54
userland/libs/hdf5/hello_cpp.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
// Adapted from: https://support.hdfgroup.org/HDF5/doc/cpplus_RM/create_8cpp-example.html
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <H5Cpp.h>
|
||||||
|
|
||||||
|
using namespace H5;
|
||||||
|
|
||||||
|
const H5std_string FILE_NAME("hello_cpp.tmp.h5");
|
||||||
|
const H5std_string DATASET_NAME("IntArray");
|
||||||
|
const int NX = 5;
|
||||||
|
const int NY = 6;
|
||||||
|
const int RANK = 2;
|
||||||
|
|
||||||
|
int main (void) {
|
||||||
|
// 0 1 2 3 4 5
|
||||||
|
// 1 2 3 4 5 6
|
||||||
|
// 2 3 4 5 6 7
|
||||||
|
// 3 4 5 6 7 8
|
||||||
|
// 4 5 6 7 8 9
|
||||||
|
int i, j;
|
||||||
|
int data[NX][NY];
|
||||||
|
for (j = 0; j < NX; j++) {
|
||||||
|
for (i = 0; i < NY; i++)
|
||||||
|
data[j][i] = i + j;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a new file using H5F_ACC_TRUNC access,
|
||||||
|
//default file creation properties, and default file
|
||||||
|
//access properties.
|
||||||
|
H5File file(FILE_NAME, H5F_ACC_TRUNC);
|
||||||
|
|
||||||
|
// Define the size of the array and create the data space for fixed
|
||||||
|
// size dataset.
|
||||||
|
hsize_t dimsf[2];
|
||||||
|
dimsf[0] = NX;
|
||||||
|
dimsf[1] = NY;
|
||||||
|
DataSpace dataspace(RANK, dimsf);
|
||||||
|
|
||||||
|
// Define datatype for the data in the file.
|
||||||
|
// We will store little endian INT numbers.
|
||||||
|
IntType datatype(PredType::NATIVE_INT);
|
||||||
|
datatype.setOrder(H5T_ORDER_LE);
|
||||||
|
|
||||||
|
// Create a new dataset within the file using defined dataspace and
|
||||||
|
// datatype and default dataset creation properties.
|
||||||
|
DataSet dataset = file.createDataSet(DATASET_NAME, datatype, dataspace);
|
||||||
|
|
||||||
|
// Write the data to the dataset using default memory space, file
|
||||||
|
// space, and transfer properties.
|
||||||
|
dataset.write(data, PredType::NATIVE_INT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
userland/libs/hdf5/test
Symbolic link
1
userland/libs/hdf5/test
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../test
|
||||||
Reference in New Issue
Block a user