Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add device conversion for uint64 #1373

Merged
merged 14 commits into from
Sep 17, 2024

Conversation

nicolemarsaglia
Copy link
Contributor

No description provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyrush I'm not committed to having this be the file we use for the conversion. but I can't get it all to link. am I missing something else in the cmake?

This is the error I'm getting:

[ 85%] Linking CXX executable lulesh_ser
cd /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/build/ascent-develop/examples/proxies/lulesh2.0.3 && /usr/tce/packages/cmake/cmake-3.23.1/bin/cmake -E cmake_link_script CMakeFiles/lulesh_ser.dir/link.txt --verbose=1
/usr/tce/packages/gcc/gcc-11.2.1/bin/g++ -O3 -DNDEBUG -L/usr/tce/packages/cuda/cuda-12.0.0/nvidia/lib64 -L/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-2020.08.19/lib -pthread CMakeFiles/lulesh_ser.dir/lulesh.cc.o "CMakeFiles/lulesh_ser.dir/lulesh-comm.cc.o" "CMakeFiles/lulesh_ser.dir/lulesh-viz.cc.o" "CMakeFiles/lulesh_ser.dir/lulesh-util.cc.o" "CMakeFiles/lulesh_ser.dir/lulesh-init.cc.o" -o lulesh_ser  -Wl,-rpath,/usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/build/ascent-develop/lib:/usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib:/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release/lib:/usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/raja-v2024.02.1/lib:/usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/umpire-2024.02.1/lib64:/usr/WS1/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/mfem-4.6/lib:/usr/WS1/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/zlib-1.3/lib:/usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/camp-v2024.02.1/lib:/usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/conduit-v0.9.1/lib:/usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/hdf5-1.14.1-2/lib: ../../../lib/libascent.so ../../../lib/libascent_flow.so ../../../lib/librover.so ../../../lib/libvtkh_rendering.so ../../../lib/libvtkh_filters.so ../../../lib/libvtkh_compositing.so ../../../lib/libvtkh_core.so ../../../lib/libvtkh_utils.so /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_connected_components-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_contour-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_vector_analysis-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_mesh_info-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_field_conversion-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_field_transform-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_flow-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_multi_block-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_resampling-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_density_estimate-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_geometry_refinement-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_scalar_topology-2.1.so.2.1.0 /usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release/lib/libmpiprofilesupport.so /usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release/lib/libmpi_ibm.so /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_zfp-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_rendering-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_entity_extraction-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_clean_grid-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_image_processing-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_filter_core-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_worklet-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_io-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkm_cont-2.1.so.2.1.0 /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/vtk-m-v2.1.0/lib/libvtkmdiympi.so.2.1.0 ../../../lib/libdray.so /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/raja-v2024.02.1/lib/libRAJA.so /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/umpire-2024.02.1/lib64/libumpire.so /usr/WS1/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/mfem-4.6/lib/libmfem.so -Wl,-rpath,/usr/WS1/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/conduit-v0.9.1/lib -L/usr/WS1/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/conduit-v0.9.1/lib -lconduit -lconduit_relay -lconduit_blueprint /usr/WS1/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/zlib-1.3/lib/libz.so /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/camp-v2024.02.1/lib/libcamp.so /usr/tce/packages/cuda/cuda-12.0.0/nvidia/lib64/libcudart_static.a /usr/lib64/librt.so ../../../lib/libapcomp.so /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/conduit-v0.9.1/lib/libconduit_relay.so -lpthread -lrt /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/hdf5-1.14.1-2/lib/libhdf5.so.310.1.0 -ldl /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/conduit-v0.9.1/lib/libconduit_blueprint.so /usr/workspace/nicolem/lassen/src/ascent_warpx/ascent/scripts/build_ascent/install/conduit-v0.9.1/lib/libconduit.so ../../../lib/libascent_lodepng.so
/usr/tce/packages/gcc/gcc-11.2.1/rh/usr/bin/../libexec/gcc/ppc64le-redhat-linux/11/ld: ../../../lib/libascent.so: undefined reference to `ascent::castUint64ToFloat64(unsigned long const*, double*, int)'
collect2: error: ld returned 1 exit status

Copy link
Member

@cyrush cyrush Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue may be that we are missing the export declaration ASCENT_API.

Also, we need to use a macro for __host__ __device__ decoration (for when cuda + hip are not there)

We can use
ASCENT_EXEC, which is defined in ascent_execution_policies.hpp

#define ASCENT_EXEC inline __host__ __device__

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyrush Thank you! I will do this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof. sorry for all the print statements from debugging warpx. ignore those. important stuff is line 1680

//---------------------------------------------------------------------------//
// Non-device decorators
//---------------------------------------------------------------------------//
static const std::string memory_space = "host";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't declare and define an instance in a header b/c that will cause multiple defs.
You can declare here and then init in cpp file.

// Lambda decorators
//---------------------------------------------------------------------------//

#if defined(__CUDACC__) && !defined(DEBUG_CPU_ONLY)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use ascent's CUDA ifdefs instead of the compiler defines

ASCENT_EXEC void
VTKHDeviceAdapter::castUint64ToFloat64(const uint64_t* input, double* output, int size) {
Array<double> int_to_double(input, size);
output = int_to_double.get_ptr(memory_space);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array<double> int_to_double(input, size);

I don't think this strategy will work. Creating a double array that points to the integer input.

@cyrush
Copy link
Member

cyrush commented Sep 5, 2024

@nicolemarsaglia
Since this is in vtk-h -- I am thinking maybe we should be using a vtk-m worklet after all?

Sorry for flip flopping on this, but seems like the right path. Can you look into what that will take?

@nicolemarsaglia
Copy link
Contributor Author

@nicolemarsaglia Since this is in vtk-h -- I am thinking maybe we should be using a vtk-m worklet after all?

Sorry for flip flopping on this, but seems like the right path. Can you look into what that will take?

All good! I have been thinking the same thing. Wish me luck!!

vtkm::cont::Invoker invoker;
vtkh::VTKmTypeCast worklet;

invoker(worklet,input_arr,vtkm_arr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice easy to use solution!

@@ -12,5 +13,25 @@ GetVTKMPointer(vtkm::cont::ArrayHandle<T> &handle)
return handle.WritePortal().GetArray();
}

class VTKmTypeCast : public vtkm::worklet::WorkletMapField
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@@ -1891,68 +1893,97 @@ VTKHDataAdapter::AddField(const std::string &field_name,
// Array: valueType=x storageType=N4vtkm4cont15StorageTagBasicE 27 values occupying 216 bytes [0 1 2 ... 24 25 26]
// TypeList: N4vtkm4ListIJfdEEE
// ***********************************************************************
// ***********************************************************************
// NOTE: int32 should work as of sept 10 2024
// ***********************************************************************
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VTK-m 2.2, or later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should have always worked, and it was working when I uncommented it, but the errors previously encountered make me too nervous to commit to changing it from something that works to something that might work sometimes. So I just left a note and if the else catch-all stops working for int32s we can try changing it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for clarifying.

@nicolemarsaglia nicolemarsaglia merged commit af8498b into develop Sep 17, 2024
22 checks passed
@nicolemarsaglia nicolemarsaglia deleted the task/08_2024_uint64_gpu_conversion branch September 17, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants