前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >C++11:模板实现opencl向量类型的简单运算符重载及length,distance函数

C++11:模板实现opencl向量类型的简单运算符重载及length,distance函数

作者头像
10km
发布于 2019-05-25 14:37:25
发布于 2019-05-25 14:37:25
1.7K00
代码可运行
举报
文章被收录于专栏:10km的专栏10km的专栏
运行总次数:0
代码可运行

版权声明:本文为博主原创文章,转载请注明源地址。 https://cloud.tencent.com/developer/article/1433754

主机端opencl向量的运算能不能像在内核代码中一样简单?

opencl内核支持的所有向量数据类型(intn,floatn,doublen….)在主机端都有对应的类型,区别是加了前缀cl_,比如int4对应的主机端类型是cl_int4

我们知道,在opencl内核代码中,向量类型(vector data type)的数据可以像普通标量类型(scala data type)一样,用各种算术和逻辑运算符进行操作。

比如:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
int4 p1=int4(4,2,0,9);
int4 p2=int4(3,9,-1,8);
int4 p3=p1+p2;
float length=length(as_float(p1));//计算向量长度

非常方便,有时候,我们也需要在主机端代码中对这种向量类型的数据进行一些处理,但c/c++以及opencl的API本身并没有提供对这些向量类型的一般运算支持。当有项目中有多个地方需要在主机端进行向量数据的运算时,就会比较痛苦。比如上面的两个向量相加,在主机端就要写成这样:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
cl_int4 p1={4,2,0,9};
cl_int4 p2={3,9,-1,8};
cl_int4 p3={p1.x+p2.x,p1.y+p2.y,p1.z+p2.z,p1.w+p2.w};
cl_float length=std::sqrt(
     std::pow(float(p1.x),2)
    +std::pow(float(p1.y),2)
    +std::pow(float(p1.z),2)
    +std::pow(float(p1.w),2));//计算向量长度

这还只是4个元素的向量,如果是16个元素的向量,这代码更长,很容易出错。

如果能像模板内核代码一样,为向量运算符提供简单的向量运算功能,就可以大大简化这些代码。

利用C++的模板计算函数,可以实现上面的功能。下面是实现代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#include <type_traits>
// 设置当opencl出错时抛出异常
#ifndef __CL_ENABLE_EXCEPTIONS
#define __CL_ENABLE_EXCEPTIONS
#endif
// gcc 下如果定义了__STRICT_ANSI__,就没办法使用别名访问vector向量类型(cl_int2,cl_float8...)
#if defined( __GNUC__) && defined( __STRICT_ANSI__ )
#define __STRICT_ANSI__DEFINED__
// 删除__STRICT_ANSI__定义
#undef __STRICT_ANSI__
#endif
#include <CL/cl.hpp>
#ifdef __STRICT_ANSI__DEFINED__
#undef __STRICT_ANSI__DEFINED__
// 恢复__STRICT_ANSI__定义
#define __STRICT_ANSI__
#endif
namespace cl{
/* 根据向量元素类型和向量长度返回opencl向量类型,
 * 如 cl_vector_type<2,cl_int>::type 为 cl_int2
 */
template<int SIZE,typename T>
struct cl_vector_type{
    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_char>::value, cl_char2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_char>::value, cl_char4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_char>::value, cl_char8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_char>::value,cl_char16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_uchar>::value, cl_uchar2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_uchar>::value, cl_uchar4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_uchar>::value, cl_uchar8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_uchar>::value,cl_uchar16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_short>::value, cl_short2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_short>::value, cl_short4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_short>::value, cl_short8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_short>::value,cl_short16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_ushort>::value, cl_ushort2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_ushort>::value, cl_ushort4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_ushort>::value, cl_ushort8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_ushort>::value,cl_ushort16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_int>::value, cl_int2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_int>::value, cl_int4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_int>::value, cl_int8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_int>::value,cl_int16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_uint>::value, cl_uint2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_uint>::value, cl_uint4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_uint>::value, cl_uint8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_uint>::value,cl_uint16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_long>::value, cl_long2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_long>::value, cl_long4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_long>::value, cl_long8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_long>::value,cl_long16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_ulong>::value, cl_ulong2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_ulong>::value, cl_ulong4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_ulong>::value, cl_ulong8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_ulong>::value,cl_ulong16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_float>::value, cl_float2>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_float>::value, cl_float4>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_float>::value, cl_float8>::type vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_float>::value,cl_float16>::type vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if< 2== _SIZE&&std::is_same<_T,cl_double>::value, cl_double2>::type  vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 4== _SIZE&&std::is_same<_T,cl_double>::value, cl_double4>::type  vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if< 8== _SIZE&&std::is_same<_T,cl_double>::value, cl_double8>::type  vector_type(_T);
    template<int _SIZE,typename _T>static typename std::enable_if<16== _SIZE&&std::is_same<_T,cl_double>::value,cl_double16>::type  vector_type(_T);

    template<int _SIZE,typename _T>static typename std::enable_if<2!= _SIZE && 4 != _SIZE && 8 != _SIZE &&16 != _SIZE>::type vector_type(...);
    using type=decltype(vector_type<SIZE>(std::declval<T>()));
};
/*
 * 根据opencl 向量类型返回向量的元素类型和向量长度,
 * 如is_cl_vector<cl_int2>::type 为 cl_int
 *  is_cl_vector<cl_int2>::value 为true 是opencl向量类型
 *  is_cl_vector<cl_int2>::size 为向量长度
 */
template<typename T>
struct is_cl_vector{
    template<typename _T, typename ENABLE=void>
    struct vector_size{
        enum{size=-1};
    };
    template<typename _T>
    struct vector_size<_T, typename std::enable_if<
        std::is_same<_T, cl_char2>::value
        || std::is_same<_T, cl_uchar2>::value
        || std::is_same<_T, cl_short2>::value
        || std::is_same<_T, cl_ushort2>::value
        || std::is_same<_T, cl_int2>::value
        || std::is_same<_T, cl_uint2>::value
        || std::is_same<_T, cl_long2>::value
        || std::is_same<_T, cl_ulong2>::value
        || std::is_same<_T, cl_float2>::value
        || std::is_same<_T, cl_double2>::value
    >::type>{
        enum{size=2};
    };
    template<typename _T>
    struct vector_size<_T, typename std::enable_if<
        std::is_same<_T, cl_char4>::value
        || std::is_same<_T, cl_uchar4>::value
        || std::is_same<_T, cl_short4>::value
        || std::is_same<_T, cl_ushort4>::value
        || std::is_same<_T, cl_int4>::value
        || std::is_same<_T, cl_uint4>::value
        || std::is_same<_T, cl_long4>::value
        || std::is_same<_T, cl_ulong4>::value
        || std::is_same<_T, cl_float4>::value
        || std::is_same<_T, cl_double4>::value
    >::type>{
        enum{size=4};
    };
    template<typename _T>
    struct vector_size<_T, typename std::enable_if<
        std::is_same<_T, cl_char8>::value
        || std::is_same<_T, cl_uchar8>::value
        || std::is_same<_T, cl_short8>::value
        || std::is_same<_T, cl_ushort8>::value
        || std::is_same<_T, cl_int8>::value
        || std::is_same<_T, cl_uint8>::value
        || std::is_same<_T, cl_long8>::value
        || std::is_same<_T, cl_ulong8>::value
        || std::is_same<_T, cl_float8>::value
        || std::is_same<_T, cl_double8>::value
    >::type>{
        enum{size=8};
    };
    template<typename _T>
    struct vector_size<_T, typename std::enable_if<
        std::is_same<_T, cl_char16>::value
        || std::is_same<_T, cl_uchar16>::value
        || std::is_same<_T, cl_short16>::value
        || std::is_same<_T, cl_ushort16>::value
        || std::is_same<_T, cl_int16>::value
        || std::is_same<_T, cl_uint16>::value
        || std::is_same<_T, cl_long16>::value
        || std::is_same<_T, cl_ulong16>::value
        || std::is_same<_T, cl_float16>::value
        || std::is_same<_T, cl_double16>::value
    >::type>{
        enum{size=16};
    };

    static cl_char check(cl_char2);
    static cl_char check(cl_char4);
    static cl_char check(cl_char8);
    static cl_char check(cl_char16);

    static cl_uchar check(cl_uchar2);
    static cl_uchar check(cl_uchar4);
    static cl_uchar check(cl_uchar8);
    static cl_uchar check(cl_uchar16);

    static cl_short check(cl_short2);
    static cl_short check(cl_short4);
    static cl_short check(cl_short8);
    static cl_short check(cl_short16);

    static cl_ushort check(cl_ushort2);
    static cl_ushort check(cl_ushort4);
    static cl_ushort check(cl_ushort8);
    static cl_ushort check(cl_ushort16);

    static cl_int check(cl_int2);
    static cl_int check(cl_int4);
    static cl_int check(cl_int8);
    static cl_int check(cl_int16);

    static cl_uint check(cl_uint2);
    static cl_uint check(cl_uint4);
    static cl_uint check(cl_uint8);
    static cl_uint check(cl_uint16);

    static cl_long check(cl_long2);
    static cl_long check(cl_long4);
    static cl_long check(cl_long8);
    static cl_long check(cl_long16);

    static cl_ulong check(cl_ulong2);
    static cl_ulong check(cl_ulong4);
    static cl_ulong check(cl_ulong8);
    static cl_ulong check(cl_ulong16);

    static cl_float check(cl_float2);
    static cl_float check(cl_float4);
    static cl_float check(cl_float8);
    static cl_float check(cl_float16);

    static cl_double check(cl_double2);
    static cl_double check(cl_double4);
    static cl_double check(cl_double8);
    static cl_double check(cl_double16);
    static void check(...);
    using type=decltype(check(std::declval<T>()));
    enum{value=!std::is_void<type>::value,size=vector_size<T>::size};
};

template<typename T,typename C=float
        ,typename RET=typename std::enable_if<std::is_arithmetic<T>::value,typename std::conditional<std::is_floating_point<T>::value,T,C>::type>::type>
inline
RET
length(const T &x,const T &y){
    return RET(std::sqrt(std::pow(RET(x),2)+std::pow(RET(y),2)));
}
/*
 * 递归计算向量所有元素的平方和(递归结束)
 * */
template<typename T,typename C=float,typename VI=is_cl_vector<T>
        ,typename RET=typename std::conditional<std::is_floating_point<typename VI::type>::value,T,C>::type>
inline
typename std::enable_if<2==VI::size&&VI::value,RET>::type
square_sum(const T &pos){
    return RET(std::pow(RET(pos.s[0]),2)+std::pow(RET(pos.s[1]),2));
}
/*
 * 递归计算向量所有元素的平方和
 * */
template<typename T,typename C=float,typename VI=is_cl_vector<T>
    ,typename RET=typename std::conditional<std::is_floating_point<typename VI::type>::value,T,C>::type>
inline
typename std::enable_if<2<VI::size&&VI::value,RET>::type
square_sum(const T &pos){
    return square_sum(pos.hi)+square_sum(pos.lo);
}
template<typename T,typename C=float,typename VI=is_cl_vector<T>
        ,typename RET=typename std::enable_if<VI::value,typename std::conditional<std::is_floating_point<typename VI::type>::value,T,C>::type>::type>
inline
RET
length(const T &pos){
    return RET(std::sqrt(square_sum(pos)));
}

template<typename T,typename C=float,typename VI = cl::is_cl_vector<T>
        ,typename RET=typename std::enable_if<VI::value,typename std::conditional<std::is_floating_point<typename VI::type>::value,T,C>::type>::type>
inline
RET
distance(const T &p0,const T &p1){
    return length(p0-p1);
}
}/* namespace cl */

////////////////begin global namespace//////////////
/*
 * (递归结束)向量减法操作符
 */
template<typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value>::type
    , typename RET= typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] - declval<T>().s[0])>::type>
inline
typename std::enable_if<2 == VI::size, RET>::type
operator-(const T &p1, const T &p2) {
    return{ p1.s[0] - p2.s[0],p1.s[1] - p2.s[1] };
}
/*
 * (递归)向量减法操作符
 */
template<typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value>::type
    , typename RET = typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] - declval<T>().s[0])>::type>
inline
typename std::enable_if<2<VI::size, RET>::type
operator-(const T &p1, const T &p2) {
    RET r;
    r.hi = p1.hi - p2.hi;
    r.lo = p1.lo - p2.lo;
    return r;
}
/*
 * (递归结束)向量减法操作符,第二个操作数非向量
 */
template<typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value>::type
    , typename RET= typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] - declval<T>().s[0])>::type>
inline
typename std::enable_if<2 == VI::size, RET>::type
operator-(const T &p1, const typename VI::type &p2) {
    return{ p1.s[0] - p2,p1.s[1] - p2};
}
/*
 * (递归)向量减法操作符,第二个操作数非向量
 */
template<typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value>::type
    , typename RET = typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] - declval<T>().s[0])>::type>
inline
typename std::enable_if<2<VI::size, RET>::type
operator-(const T &p1, const typename VI::type &p2) {
    RET r;
    r.hi = p1.hi - p2;
    r.lo = p1.lo - p2;
    return r;
}
/*
* (递归结束)向量减法操作符,第一个操作数非向量
*/
template<typename N, typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value&&std::is_same<N, typename VI::type>::value>::type
    , typename RET = typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] - declval<T>().s[0])>::type>
    inline
    typename std::enable_if<2==VI::size, RET>::type
    operator-(const N &p1, const  T&p2) {
    return{ p1 - p2.s[0],p1 - p2.s[1] };
}

/*
 * (递归)向量减法操作符,第一个操作数非向量
 */
template<typename N,typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value&&std::is_same<N, typename VI::type>::value>::type
    , typename RET = typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] - declval<T>().s[0])>::type>
inline
typename std::enable_if<2<VI::size, RET>::type
operator-(const N &p1, const  T&p2) {
    RET r;
    r.hi = p1 - p2.hi;
    r.lo = p1 - p2.hi;
    return r;
}
/*
 * (递归结束)向量加法操作符
 */
template<typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value>::type
    , typename RET= typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] + declval<T>().s[0])>::type>
inline
typename std::enable_if<2 == VI::size, RET>::type
operator+(const T &p1, const T &p2) {
    return{ p1.s[0] + p2.s[0],p1.s[1] + p2.s[1] };
}
/*
 * (递归)向量加法操作符
 */
template<typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value>::type
    , typename RET = typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] + declval<T>().s[0])>::type>
inline
typename std::enable_if<2<VI::size, RET>::type
operator+(const T &p1, const T &p2) {
    RET r;
    r.hi = p1.hi + p2.hi;
    r.lo = p1.lo + p2.lo;
    return r;
}
/*
 * (递归结束)向量加法操作符,第二个操作数非向量
 */
template<typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value>::type
    ,typename RET=typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] + declval<T>().s[0])>::type>
inline
typename std::enable_if<2 == VI::size, RET>::type
operator+(const T &p1, const typename VI::type &p2) {
    return{ p1.s[0] + p2,p1.s[1] + p2 };
}
/*
 * (递归)向量加法操作符,第二个操作数非向量
 */
template<typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value>::type
    , typename RET = typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] + declval<T>().s[0])>::type>
inline
typename std::enable_if<2<VI::size, RET>::type
operator+(const T &p1, const typename VI::type &p2) {
    RET r;
    r.hi = p1.hi + p2;
    r.lo = p1.lo + p2;
    return r;
}

/*
 * 向量加法操作符,第一个操作数非向量
 */
template<typename N,typename T, typename VI = cl::is_cl_vector<T>
    , typename ENABLE = typename std::enable_if<VI::value&&std::is_same<N, typename VI::type>::value>::type
    , typename RET = typename cl::cl_vector_type<VI::size, decltype(declval<T>().s[0] + declval<T>().s[0])>::type>
inline
RET
operator+(const N &p1, const  T&p2) {
    return p2+p1;
}
////////////////end global namespace//////////////

上面的代码中实现了opencl向量类型的+,-运算,支持两个向量类型数据的加/减运算,以及一个向量和一个标量类型的加/减运算,以及legnth,distance函数。(实现其他的运算符和函数也是差不多的代码,因为我暂时不需要就没有继续写下去)。

代码开始有两个很长的模板函数cl_vector_typeis_cl_vector,所有的其他函数模板都要用到这两个模板函数:

cl_vector_type用于构造一个指定元素类型和长度的opencl向量类型。

is_cl_vector则用于判断一个类型是否是opencl的向量类型,如果是value为true,size中保存向量长度,type则是向量元素的类型。

有了这些模板函数的支持,主机端opencl向量的运算就变得像在内核代码中一样简单,还以前面的例子用模板函数重写,就是这样:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
cl_int4 p1={4,2,0,9};
cl_int4 p2={3,9,-1,8};
cl_int4 p3=p1+p2;
cl_float length=cl::length(p1);//计算向量长度
cl_float dist=cl::distance(p1,p2);//计算向量距离
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016年04月11日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
Linux安装tomcat,配置环境变量
一、 安装tomcat需要先配置jdk,所以没有配置jdk同学,先移步Linux安装JDK
全栈程序员站长
2022/09/05
3.8K0
Linux学习-vmware虚拟机安装tomcat
/usr/local/tomcat/bin/startup.sh //启动tomcat
全栈程序员站长
2022/02/25
1.3K0
Linux学习-vmware虚拟机安装tomcat
Ubuntu 18.04 安装 Hadoop系统环境
安装ubuntu-server系统 安装系统 选择系统语言-English 键盘设置-Chinese 选择操作Install ubuntu 设置网络(这里选择默认) 选择Done 文件系统设置-选择使
吟风者
2019/07/24
7570
Centos7 安装 Tomcat8 的正确姿势 并设置开机自启 实践笔记
我使用centos7X64最小化安装 CentOS-7-x86_64-Minimal-1708
cookily
2020/09/11
1.3K0
在Linux上面装jdk,一步一步带你安装
以上的local文件夹下就有一个jdk的文件夹,里面就是jdk的东西了,我们就解压成功了
一写代码就开心
2024/01/10
2240
在Linux上面装jdk,一步一步带你安装
SpringCloud (五) - 云服务器Centos7.6,安装JDK,Maven,Mysql,Redis
购买地址:https://cloud.tencent.com/act/pro/2022double11_warmup
化羽羽
2022/11/14
1.5K0
SpringCloud (五) - 云服务器Centos7.6,安装JDK,Maven,Mysql,Redis
Linux安装Tomcat并发布项目
点击 Download 后会进去另一个页面,这里可以选择我们想要版本,图中箭头指向的就是我们Linux使用的版本。
叫我阿杰好了
2022/11/07
1.2K0
Linux安装Tomcat并发布项目
CentOS 安装 nginx+tomcat+java+mysql运行环境
本文介绍了CentOS7 64 Java,Tomcat,MySQL,Maven热部署等服务器环境的搭建过程。
haikangweishi
2020/03/24
1.7K0
Linux各种常用开发软件安装教程(JDK、Tomcat、MySQL、Nginx、Redis)
-A INPUT -m state --state NEW -m tcp -p tcp --dport 你要开放的端口 -j ACCEPT
青山师
2023/05/05
5080
CentOS6环境下JDK、MySQL、Tomcat安装
          vi /etc/sysconfig/network-scripts/ifcfg-eth0
挽风
2021/04/13
5260
CentOS6环境下JDK、MySQL、Tomcat安装
Linux下安装Zookeeper、Redis、Nexus和Jenkins
公司搞了个新的服务器,啥也没有,让我部署项目上去(本来老板是问我会不会,我想着我博客就是自己部署的,就说了会),没想到搞了两天。
sunonzj
2022/06/21
4.7K0
Linux下安装Zookeeper、Redis、Nexus和Jenkins
腾讯云服务器 java+mysql+tomcat+maven 环境搭建(ContOS7)
【1】进入:http://tomcat.apache.org/download-80.cgi,下载.tar.gz的压缩包
用户2416682
2019/10/31
2.1K0
Linux使用
Liunx使用 命令管道连接 | 命令管道符合为|,可以将两个命令进行连接,连接后第一个命令的输出结果作为第二个命令的输入信息 比如 ls /ect | more -10 分屏显示etc文件夹下的10行数据 Linux文件系统结构 / : 根目录 /home: 主文件夹,登录用户的主文件夹 /etc :操作系统配置文件的保存位置 /usr : 用于添加的程序文件,用户的很多应用程序和文件都放在这个目录下,类似于windows下的program files目录。 root : 超级用户的目录 改变当前
爱撒谎的男孩
2018/06/06
7.4K3
Linux搭建环境的详细步骤(一)
服务器上Linux的登录账号一般都是root,密码是你自己设置的密码,如果是Liunx在虚拟机上,那账号和密码就是你的登录的账号和密码。
测试小兵
2019/08/30
5.4K1
Linux搭建环境的详细步骤(一)
记录 linux 下 部署 tomcat
此文章记录了我在VM虚拟机上安装tomcat,并部署webApp,因为我这个项目的是在windows server2003下运行的,所以自己没事研究一下如何部署到linux上面,我用的是 CentOS 6.8 ,附上下载地址
全栈程序员站长
2022/07/05
5K0
快速上手 Linux 系统部署 Java 项目(附安装包、文档、视频)!
VMware Workstation 是一款桌面虚拟计算机软件,可在一部实体机器上模拟完整的网络环境,我们通过 VMware 可以在单一的桌面上同时运行不同的操作系统,进行代码的开发、测试 、部署。
南风
2020/05/13
2.2K0
快速上手 Linux 系统部署 Java 项目(附安装包、文档、视频)!
本章目标: 将SSM项目及数据库完整的部署CentOS7
 jdk1.8+tomcat8.5+mysql5.7 🙃🙃1. 上传及下载文件    1.1 安装及使用lrzsz    1.2 上传: rz    1.3 下载: sz 文件名 🙃🙃2. 上传jdk和tomcat的安装文件到指定文件夹  mkdir /usr/local/mytools   🎃🎃  注1:安装见资料 apache-tomcat-8.5.20.tar.gz         jdk-8u151-linux-x64.tar.gz 🙃🙃3. linux压缩和解压命令
用户10196776
2022/11/22
6920
本章目标: 将SSM项目及数据库完整的部署CentOS7
Linux下安装JDK1.8、Tomcat、以及MySQL详细介绍(附软件分享)
1、通过相关软件或拖拽的形式将安装包放入Linux目录中 2、解压jdk 1.8.0_11并将jdk复制到 /usr/local目录下
时间静止不是简史
2020/07/27
7920
Linux下安装JDK1.8、Tomcat、以及MySQL详细介绍(附软件分享)
Linux系统上安装JDK、Tomcat以及Redis
首先检查Linux系统上是否有JDK,一般Linux系统会有默认的openJDK,将其卸载掉。
Java阿呆
2020/11/04
1.4K0
Linux系统上安装JDK、Tomcat以及Redis
tomcat安装并设置开机自启(Linux&&Windows)
Tomcat是其中一个开源的且免费的java Web服务器,是Apache软件基金会的项目,所以安装Tomcat之前要安装java JDk,请参照Linux安装jdk
鱼找水需要时间
2023/02/16
3.2K0
tomcat安装并设置开机自启(Linux&&Windows)
推荐阅读
相关推荐
Linux安装tomcat,配置环境变量
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验